19

How do you associate a specific file type to an application on a Windows (Vista) PC?

2

7 Answers 7

14

Method #1 (on the fly):

  1. Right-click a file of the type you want to change, and select Properties.
  2. In the General tab, click the Change button.
  3. Choose a program from the list, or click Browse to select an .EXE file on your hard disk.

Method #2 (view a list of file types):

  1. Open Control Panel.
  2. In Control Panel Home, click Programs, and then click Make a file type always open in a specific program.

    Or, in the Classic View, open Default Programs and then click Associate a file type or protocol with a program.

  3. Highlight a file type in the list and click Change Program.

Unfortunately, neither method in Vista allows you to choose anything but the default programs, such as the programs listed in your files' context menus. If you want complete control over your file types, use this tool:

Method #3 (File Type Doctor):

  1. Download and install Creative Element Power Tools.
  2. Open the Creative Element Power Tools Control Panel.
  3. Turn on the Edit file type associations option, and click Accept.
  4. Right-click a file of the type you want to change, and select Edit File Type to show this window:

alt text

Source

1
27

How about Method #5 (for people who like the command line):

  1. Open an elevated command prompt.
  2. Use FTYPE {fileType}={commandString} to create a file type and associated command to open the file.
  3. Use ASSOC {.fileExtension}={fileType} to associate a file extension with the file type you created.

Example:

FTYPE MyCustomType=C:\Program Files\MyCustomProgram\MyProg.exe "%1"
ASSOC .custom=MyCustomType

Note that many file types may already be registered on your system. You can list them all by just typing FTYPE with no arguments.

3
  • thanks. I just tried with "assoc .=MyCustomType" for files with no extension, and it worked!
    – gulbrandr
    Nov 21, 2010 at 19:43
  • Something is wrong. Currently, .js files are opening with Sublime Text 2, and assoc .js command gives me .js=jsfile and ftype jsfile command gives me jsfile=%SystemRoot%\System32\WScript.exe "%1" %*. Jul 6, 2014 at 15:07
  • Doesn't work with PDF (Windows 10). MS Edge persists in "owning" PDF even after ASSOC.
    – user53621
    Mar 18 at 14:18
5

Adding Method #4:

  1. Right click on a file of the type you wish to change
  2. Click Open With... (select Choose Default Program... if a sub-menu appears)
  3. Select the application you wish to open this type of file with. You can also click the browse option if Windows doesn't suggest what you want.
  4. Ensure the box labeled Always use the selected program to open this type of file is ticked
2
  • You can add new files to the submenu this way without making them the default program. Just make sure the box mentioned in step 4 above is not ticked. (Note that there will be no "Open With..." item if the file doesn't currently have any programs associated with it.)
    – RobH
    Jul 16, 2014 at 16:40
  • Works for a day or two, then Windows 10 automatically resets PDF to MS Edge.
    – user53621
    Mar 18 at 14:19
4

The following example .bat file show how to associate a file type with a specific program and icon will not be ugly:

enter image description here

set ftypename=potato_xxx_file
set extension=.potato
set pathtoexe="C:\potato.exe"
set pathtoicon=""

if %pathtoicon%=="" set pathtoicon=%pathtoexe%,0
REG ADD HKEY_CLASSES_ROOT\%extension%\ /t REG_SZ /d %ftypename% /f
REG ADD HKLM\SOFTWARE\Classes\%ftypename%\DefaultIcon\ /t REG_SZ /d %pathtoicon% /f
ftype %ftypename%=%pathtoexe% "%%1" %%*
assoc %extension%=%ftypename%

Some hints:

ftypename - FileType name can be random but should be unique.

extension - A filename extension. Examples of filename extensions are .png, .jpeg, .exe, .dmg

pathtoexe - Full executable path.

pathtoicon - Full path to icon or executable file with selected icon. If icon path empty then default icon from exe will be used. If want use custom icon change set pathtoicon="" for example to set pathtoicon="C:\icons\potato.ico".

Works atleast in Windows 7.

2
2

I achieved the correct way of FILE ASSOCIATION using these cmd commands. this is just an example:

REG ADD "HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open\command" /v @ /t REG_SZ /d "\"C:\\Program Files\\Noteepad++\\notepad++.exe\" \"%1\"" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt" /v "Application" /t REG_SZ /d "notepad++.exe" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithList" /v "g" /t REG_SZ /d "notepad++.exe" /f

assoc .txt=MyCustomType
ftype MyCustomType="C:\Program Files\Noteepad++\notepad++.exe" "%1"

(it's better to put them in .bat file)

0

I didn't think people used .bat any more, switched to .cmd a while ago. Anyway, we are trying to restore default to Adobe Reader for PDFs after installing Acrobat.

Doing exactly what the last guy did and it still doesn't change. I don't know if anyone can see where I made a mistake or just are seeing the same thing, and yes I know how to change it in the GUI, but this is for a mass deployment so keep that to yourselves-

REG ADD "HKEY_CLASSES_ROOT\Applications\AcroRD32.exe\shell\Read\command" /v @ /t REG_SZ /d "\"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe\" \"%1\"" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pdf" /v "Application" /t REG_SZ /d "AcroRd32.exe" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.pdf\OpenWithList" /v "g" /t REG_SZ /d "AcroRd32.exe" /f

ftype "PDF File"="C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" "%1"
assoc .pdf="PDF File"
2
  • 1
    If you run these commands from CMD, then use %1, but if you run .bat file, then use %%1
    – T.Todua
    Jun 14, 2015 at 19:38
  • I'm guessing Microsoft has hard-coded ".PDF" to infernal Edge. Even when I use Method #4 (right-click, "Always use this program..."), it automatically reverts to Edge after a day or two.
    – user53621
    Mar 18 at 14:34
0

To sum up the above said and having corrected some escape issues in .BAT file (NOT IN CMD) it should look like this:

REG ADD "HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open\command" /v @ /t REG_SZ /d "\"D:\\Public\\englishextra\\Notepad++Portable\\notepad++.exe\" \"%%1\"" /f
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jsfile\DefaultIcon" /t REG_SZ /d "D:\Public\englishextra\Notepad++Portable\notepad++.exe,0" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.js" /v "Application" /t REG_SZ /d "notepad++.exe" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.js\OpenWithList" /v "g" /t REG_SZ /d "notepad++.exe" /f

assoc .js=jsfile
ftype jsfile=D:\Public\englishextra\Notepad++Portable\notepad++.exe %%1
1
  • 1
    (1) We frown on answers that merely summarize other answers. We do allow answers that build on previous answers, but you must identify the answer(s) that you are building on (by author’s name and link; not “the above”) and state the improvement you are making.  (2) What do you mean by “in .BAT file (NOT IN CMD)”?  (3) Every other example of an ftype command has %1 (or %%1) in quotes. Yours does not. Do you claim that your command is better because it leaves out the quotes? That would be rare.  Please do not respond in comments; edit your answer to make it clearer and more complete. Oct 9, 2018 at 16:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .