cmd

Like me, you may have run into the problem that when you go to Start > Run and type in “cmd”, you are getting prompted with an “Open With” dialog which is asking what program you would like to open cmd with. This problem can occur when there is another file named CMD on your system, typically in your profile folder.

To help locate the rouge file causing the issue you can run the following command in the Run dialog
%comspec% /k dir "%userprofile%\cmd*" /s

This line will open cmd and run the dir command on your profile searching for any files with word “cmd” in their title, and display them accordingly.

Now we want to remove the offending file using the list of files we have just created. You could delete the file, however, I would suggest renaming or moving the file to a alterative location. Using the list navigate to the paths provided rename/move/delete the file in question. You may want to do one file at a time and try entering “cmd” in the Run dialog again to determine which of the files was causing the problem.

When you type a program name into the Run dialog, Windows searches for the file in the following locations and executes the first one it finds:

  1. User Profile folder
  2. App Paths registry key
  3. Folders included in the PATH variable

If you haven’t managed to fix the problem by working through the user profile, you could next try looking through the App Paths with regedit. Enter “regedit” into the Run dialog and then navigate to “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths”. We want to delete any key which may have been created for cmd.exe. Warning: you should first backup the registry before making any changes! To do this you can select the key you are going to change, right-click the key and select export, browsing to a location you would like to save the backup. When using regedit don’t delete anything you are unsure of, as you could cause damage to your system.

If you haven’t managed to fix the issue then you have another place we can still check! Go to the PATH environmental variables by right-clicking “Computer” or “My Computer” depending upon your Operating System, select “Advanced System Settings” or “System Properties”, select the “Advanced” tab and press the “Environmental Variables” button. You should see a dialog similar to that of below. Warning: becareful not to delete any part of the PATH as you may cause damage to your system.

PATH Enviromental Variable

PATH Enviromental Variable

Much like the first step we tried earlier you can sift through the different file locations provided in the Path variable and check to see if you can find any stray “cmd” titled files. Again rename/move/delete the offending file, and test “cmd” in the Run diaglog.

Finally if you believe the files appeared on your system without your assistance, then it’s highly recommended that you run a scan for Viruses and Malware. If you have no anti-virus or anti-malware software then you could try using one of the following Malwarebytes Anti-Malware, SUPERAntiSpyware, Spybot Search & Destroy, Ad-Aware, Microsoft Security Essentials, Combofix.