Assoc ftype windows 10

Команда FTYPE — просмотр и изменение расширений файлов и сопоставленных им приложений

FTYPE используется для отображения и изменения сопоставлений типов файлов и командных строк их открытия.

Формат командной строки:

Параметры командной строки:

типФайлов — Тип файлов для просмотра или изменения сопоставления.

команднаяСтрокаОткрытия — Команда, используемая для открытия файлов указанного типа.

Команда FTYPE без параметров выводит текущий список типов файлов, для которых определены командные строки открытия. Если указан только тип файла, FTYPE выводит командную строку открытия для этого типа файлов. Если после знака равенства не указана строка открытия, FTYPE удалит текущее сопоставление для указанного типа файлов. При вызове командной строки переменные %0 и %1 заменяются на имя файла, запускаемого с помощью сопоставления. Вместо переменной %* подставляются все параметры, а переменные %2, %3 и т.д. заменяются, соответственно, на первый, второй и другие параметры. Вместо переменной %

n подставляются все оставшиеся параметры, начиная с n, где n является числом от 2 до 9. Например:

ASSOC .pl=PerlScript
FTYPE PerlScript=perl.exe %1 %*

Эти команды позволят вызывать обработчик команд Perl следующим образом:

Если желательно избежать постоянного ввода расширения имен файлов, введите следующую команду:

После чего, обработчик команд вызывается еще проще:

В большинстве случаев, команда FTYPE применяется совместно с командой ASSOC

Посмотреть, каким образом обрабатывается открытие документов Microsoft Word :

ASSOC .doc — получить информацию о типе файла, ассоциированного с расширением .doc
.doc=Word.Document.8 — ответ на ASSOC
ftype word.document.8 — отобразить командную строку для открытия файлов данного типа ( .doc )
word.document.8=»C:\Program Files\Microsoft Office\Office14\WINWORD.EXE» /n «%1» — строка запуска приложения с параметрами для открытия файлов данного типа

Удаление сопоставления типа файла и приложения:

Изменение сопоставления типа файла и приложения для его открытия:

ftype

Displays or modifies file types that are used in file name extension associations. If used without an assignment operator (=), this command displays the current open command string for the specified file type. If used without parameters, this command displays the file types that have open command strings defined.

This command is only supported within cmd.exe and is not available from PowerShell. Though you can use cmd /c ftype as a workaround.

Syntax

Parameters

Parameter Description
Specifies the file type to display or change.
Specifies the open command string to use when opening files of the specified file type.
/? Displays help at the command prompt.

Remarks

The following table describes how ftype substitutes variables within an open command string:

Variable Replacement value
%0 or %1 Gets substituted with the file name being launched through the association.
%* Gets all of the parameters.
%2 , %3 , . Gets the first parameter ( %2 ), the second parameter ( %3 ), and so on.
%

Gets all of the remaining parameters starting with the nth parameter, where n can be any number from 2 to 9.

Examples

To display the current file types that have open command strings defined, type:

To display the current open command string for the txtfile file type, type:

This command produces output similar to the following:

To delete the open command string for a file type called example, type:

To associate the .pl file name extension with the PerlScript file type and enable the PerlScript file type to run PERL.EXE, type the following commands:

To eliminate the need to type the .pl file name extension when invoking a Perl script, type:

ftype ftype

Отображает или изменяет типы файлов, которые используются при сопоставлении расширений имен файлов. Displays or modifies file types that are used in file name extension associations. Если используется без оператора присваивания (=), эта команда отображает текущую командную строку открытия для указанного типа файла. If used without an assignment operator (=), this command displays the current open command string for the specified file type. При использовании без параметров эта команда отображает типы файлов, для которых определены строки открытых команд. If used without parameters, this command displays the file types that have open command strings defined.

Эта команда поддерживается только в cmd.exe и недоступна в PowerShell. This command is only supported within cmd.exe and is not available from PowerShell. Хотя это решение можно использовать в cmd /c ftype качестве обходного пути. Though you can use cmd /c ftype as a workaround.

Синтаксис Syntax

Параметры Parameters

Параметр Parameter Описание Description
Указывает тип файла для просмотра или изменения. Specifies the file type to display or change.
Указывает командную строку открытия, используемую при открытии файлов указанного типа. Specifies the open command string to use when opening files of the specified file type.
/? /? Отображение справки в командной строке. Displays help at the command prompt.

Комментарии Remarks

В следующей таблице описано, как команда ftype заменяет переменные в строке открытой команды: The following table describes how ftype substitutes variables within an open command string:

Переменная Variable Заменяющее значение Replacement value
%0 либо %1 %0 or %1 Заменяется именем файла, запускаемым через ассоциацию. Gets substituted with the file name being launched through the association.
%* Возвращает все параметры. Gets all of the parameters.
%2 , %3 , . %2 , %3 , . Получает первый параметр ( %2 ), второй параметр ( %3 ) и т. д. Gets the first parameter ( %2 ), the second parameter ( %3 ), and so on.
%

Возвращает все оставшиеся параметры, начиная с n-го параметра, где n может быть любым числом от 2 до 9. Gets all of the remaining parameters starting with the n th parameter, where n can be any number from 2 to 9.

Примеры Examples

Чтобы отобразить текущие типы файлов с определенными командными строками открытия, введите: To display the current file types that have open command strings defined, type:

Чтобы отобразить текущую командную строку открытия для типа файла ткстфиле , введите: To display the current open command string for the txtfile file type, type:

Выходные данные этой команды выглядят примерно следующим образом: This command produces output similar to the following:

Чтобы удалить командную строку открытия для типа файла с именем example, введите: To delete the open command string for a file type called example, type:

Чтобы связать расширение PL с типом файла Перлскрипт и включить тип файла Перлскрипт для запуска PERL.EXE, введите следующие команды: To associate the .pl file name extension with the PerlScript file type and enable the PerlScript file type to run PERL.EXE, type the following commands:

Чтобы исключить необходимость ввода расширения имени файла с расширением PL при вызове сценария Perl, введите: To eliminate the need to type the .pl file name extension when invoking a Perl script, type:

Best way to get file type association in Windows 10 from command line?

I am aware that I can use assoc and ftype on the command line to get the file type assocation. So when i do:

I am under the impression that .html files are opened with iexplorer.

However html files are opening with chrome since chrome has been set as the default app for html files.

Why is ftype giving me iexplorer when indeed the program opens with chrome?

2 Answers 2

It seems that ftype and assoc are pretty useless on systems running Windows 8 or later.

This is due to the fact that Microsoft decided in Windows 8 that users should be able to set default programs only via the built in GUI. This probably was due to security reasons and trouble with applications hijacking file type associations.

Therefore a new registry key was introduced and Windows now writes the user choice to

The key contains a Prog-Id and a Hash Value. The correct Hash value proves that the UserChoice ProgId value was set by the user, and not by any other application. If the hash is invalid, windows will reset the user choice to the default application.

The ftype command however is not aware of the above registry key.

It reads the HKCR\htmlfile\shell\open\command\(Default) registry key and prints out the result.

Therefore the results of the ftype command therefore are not usuable to determine which application is associated with a specific file extension.

Мгновенная настройка привычных файловых ассоциаций

Автоматизировал задание файловых ассоциаций, то есть выбор программы которая будет открывать файл из Explorer/Finder. И делюсь.

Сначала проблематика. Файлы нужных расширений часто не открываются по умолчанию ничем, а если открываются, то каким-нибудь iTunes. Под windows нужные ассоциации, бывает, и вовсе теряются при установке (или даже деинсталяции) программ: снесёшь, бывало, GIMP, а ico-файлы перешли во владение от привычного просмотрщика файлов к стандартной Photo Gallery. Почему? Зачем? Неизвестно… А если нашёл новый редактор или, по разным причинам, свежая инсталляция? А если компьютер не один? В общем, кликать мышками в диалогах — развлечение такое себе.

Вместо этого я сохранил два файлика на Dropbox и теперь привести компьютерный мир к привычному состоянию можно почти мгновенно. И чего ждал столько лет… Далее рецепт для Windows и macOS.

Windows

В консоли Windows cmd.exe это делается в два этапа:

Изменения вступают в силу сразу. Несмотря на то, что ассоциация прописывается для текущего пользователя, запускать эти команды нужно почему-то с правами администратора. И не забыть задвоить символ процента (%%1) при запуске из bat-файла. Волшебный мир Windows 7 Ultimate 64-bit.

UPD. Опыты показали, что манипуляции с ftype/assoc воздействуют на всех юзеров на машине (такого поворота наша редакция не ожидала). Тем не менее, схема остаётся рабочей. Но буду выяснять как не затронуть остальных.

macOS

В макоси ассоциации удобно задавать утилитой duti. Устанавливается она через brew install duti . Пример использования:

Читайте также:  Windows 10 home лицензия для флешки
Оцените статью