What are ways to associate file from cmd?
For example,I want .txt file extension to associate with a typical program, through command prompt?
what is the correct file association cmd command?
One needs to use ftype and assoc commands as follows (and note that sequence matters):
ftype txtfile="C:\Program Files (x86)\PSPad editor\PSPad.exe" "%1"
assoc .log=txtfile
assoc .txt=txtfile
assoc .wtx=txtfile
or
ftype TIFImage.Document="C:\Program Files\MSPVIEW.exe" "%1"
assoc .tif=TIFImage.Document
assoc .tiff=TIFImage.Document
Note that I haven't MSPVIEW.exe installed so I can't approve your ftype assignment rightness. In my Windows ftype TIFImage.Document command output is as follows:
TIFImage.Document=%SystemRoot%\System32\rundll32.exe "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %1
File association with COMMAND PROMPT (using .bat file):
REG ADD "HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open\command" /v "" /t REG_SZ /d "\"C:\Program Files\\Notepad++\\notepad++.exe\" \"%%1\"" /f
::or use ---------------> REG ADD "HKEY_CLASSES_ROOT\txtfile\shell\open\command" /v "" /t REG_SZ /d "\"C:\Program Files\\Notepad++\\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
ftype txtfile="C:\Program Files\Notepad++\notepad++.exe" "%%1"
assoc .txt=txtfile
NOTE! If typing directly in CMD(instead of .bat) then use single % (instead of double %%) and single \ (instead of double \)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With