How to run a CMD file that is associated with a text editor [duplicate]
Matthew Harrington
The file extension .cmd somehow got associated with Vim on my Windows 7 machine. When I try to run the cmd file, either by double clicking or running it by typing its name into a command prompt, it opens in Vim. I need to actually run this script.
In the right click menu, there's no "Open With..." or "Run" or anything like that.
The file is shared by many people, so I cannot change it's extension or modify it in anyway.
How can I run this file? (I would consider resetting the file associate back to whatever is default to be an acceptable answer).
Edit: Worth nothing that the CMD file I need to run is on a network machine, which is accessed from an .lnk file on my machine.
51 Answer
Manual Start:
You could start cmd and passing parameters to start the file. From :
Options:
/C Run Command and then terminate
Command : The command, program or batch script to be run...
Open up the run command (WIN+R) and type in
cmd /C "Path_to_your_file"
For example:
cmd /C "C:\Users\name\Desktop\script.cmd"Reset .cmd to cmdfile association
You could also reset the file association of .cmd files to cmdfile, assuming this is what caused your .cmd files to be opened in vim: Start up the cmd as administrator and type
assoc.cmd=cmdfileReset registry
This one can cause harm to your computer if you do something wrong since you're working on the registry.
Open up regedit (WIN+R: regedit)
First we want to check if .cmd art associated with cmdfiles.
Goto: HKEY_CLASSES_ROOT\.cmd and check if the (Default) String contains the data cmdfile
Also check if HKEY_CLASSES_ROOT\cmdfile\shell\open\command contains the (Default) String "%1" %*.
If so, go to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cmd
.cmd should contain 2 Keys: OpenWithList and OpenWithProgids. If there is an UserChoice key, delete it with all its contents.
The OpenWithList should only contain a (Default) String with an empty value. It should say (value not set). Delete any other values within OpenWithList.
The OpenWithProgids should only contain a (Default) String with an empty value and a binary value with the name cmdfile. Again, delete any other values within OpenWithProgids.