Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I run cmd in Windows 7 (by typing 'cmd' in Windows Run), the following error shows:

enter image description here

'-p' is not recognized as an internal or external command, operable program or batch file.

I have tried checking PATH in environment variables. Running echo %PATH% gives me the following:

C:\Windows\System32;C:\Windows;C:\Windows\System32\WindowsPowerShell\v1.0;C:\xampp\php;

I have checked all the directories being pointed to by PATH. Everything seems to be in place. What I can not understand is where '-p' is being called. I'm thinking that it has something to do with cmd since it only comes out when I call cmd and not when I run ipconfig or ping, for example.

share|improve this question
    
How do you run 'cmd'? Do you execute a shortcut or type 'cmd' in the search box? –  Simon Mar 26 '13 at 14:09
    
@Simon, I run it using Windows Run. I updated the question. –  nmenego Mar 26 '13 at 14:12
    
check each of the directories listed there in your PATH, for cmd.* - perhaps that will provide a clue –  StevenV Mar 26 '13 at 14:14
    
This guy: stackoverflow.com/questions/10077689/… had a space before a ; in the path statement. –  edelwater Mar 26 '13 at 14:17
    
@edelwater Slightly different case there; that guy was trying to run a program called R, which should have been in his path but was not, due to that mistake. This case is of the command processor (cmd) itself raising the error on start - and the start was successful. Still, the problem that caused it might be the same; I won't discount that... –  Bob Mar 26 '13 at 14:20

1 Answer 1

up vote 6 down vote accepted

It's possible that you have an 'AutoRun' command set in the registry. There's two registry keys, one per-user and one per-computer, that can define commands that are run every time the command processor (cmd.exe) is started. They're actually listed in cmd /?.

Anyway, try running cmd /d and see if that produces the same message. The /d flag means "don't run AutoRun commands", which makes it perfect for testing this.

The registry values are:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

Check both. By default, neither should exist. You may wish to fix the command strings in yours, or even delete them entirely.

Related: http://blogs.msdn.com/b/oldnewthing/archive/2007/11/21/6447771.aspx


Alternatively, you could have a batch script or similar set up with the name cmd, which is being executed instead of the native cmd. Try the command where cmd to print out a list of cmds in your path, in order of execution. If there are any other than/before the one in C:\Windows\System32\cmd.exe, you may wish to delete them, or remove their path from your PATH environment variable.

share|improve this answer
    
I tried executing cmd /d and as expected, the problem was gone. I then checked the registry, and I found HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun some command strings with regards to ANSICON. I was not able to remove it the last time I deleted it. I simply removed the key! This is a brilliant answer! –  nmenego Mar 26 '13 at 14:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.