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:


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.

  • How do you run 'cmd'? Do you execute a shortcut or type 'cmd' in the search box?
    – Simon
    Mar 26, 2013 at 14:09
  • @Simon, I run it using Windows Run. I updated the question.
    – nmenego
    Mar 26, 2013 at 14:12
  • check each of the directories listed there in your PATH, for cmd.* - perhaps that will provide a clue
    – StevenV
    Mar 26, 2013 at 14:14
  • This guy: stackoverflow.com/questions/10077689/… had a space before a ; in the path statement.
    – edelwater
    Mar 26, 2013 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, 2013 at 14:20

1 Answer 1


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.

  • 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, 2013 at 14:27
  • Worked perfectly for me, for people now sure how to edit the registry keys in windows, see this: support.microsoft.com/en-us/windows/…. Rather straightforward. Nov 28, 2022 at 22:15
  • Ah, the good old times of actually being able to solve problems. Whatever happened to that?
    – S.S. Anne
    Nov 2, 2023 at 23:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .