Chris
Chris

Reputation: 143

Is it possible to associate a file type with a .cmd file so it sends that file as an argument when double clicked

i have a dostuff.cmd file that takes one argument and looks something like this:

filepath_to_command_to_run %1

If I type dostuff.cmd FILE into the command prompt it runs fine.

Is it even remotely possible to get it so that I can associate that file type with my dostuff.cmd so that if I double click a file the .cmd will get it as an argument? Right now I've associated the file type with it, but when I double click it runs the stuff in the .cmd without getting the file as an argument.

Upvotes: 0

Views: 1088

Answers (2)

otaxige_aol
otaxige_aol

Reputation: 341

Once I have 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)

Upvotes: 0

manojlds
manojlds

Reputation: 301117

Right click on the file -> Open With -> Choose Default Program -> Browse to and select your cmd file. ( Choose the checkbox saying always use this for this file type if you want)

Now double clicking the file will open it with the cmd file.

Alternatively, you can set it directly to filepath_to_command_to_run

Upvotes: 1

Related Questions