3

I have an HP laptop with a Windows 7 32-bit Home Premium operating system. My command prompt doesn't run lots of commands like help, shutdown, ipconfig, ping, etc. I get a message like:

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

Only simple commands like cd and dir are working. I noticed that whenever I navigate to c:/windows/system32, the command works. But I need to run some important commands like java on a file that is on the desktop and not in the system32 folder.

How can I fix this?

5
  • 1
    Please type "echo %path%" and give the output. It seems that your PATH environment variable is corrupt (cd, dir, set are built into cmd.exe, programs like shutdown, ipconfig, ping are external programs and not builtin, therefor cmd.exe needs to have a good PATH variable to find the programs). Nov 7, 2013 at 12:25
  • 1
    This might be a reason for not having c:/windows/system32 folder in the path. Open command prompt. Enter path command. See whether it contains c:\windows\system32 is in it or not. If not add it. You can use all the above mentioned commands. Nov 7, 2013 at 12:25
  • @WernerHenze This is what i get %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\Syste m32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C :\Program Files\Java\jre7\bin;
    – user264958
    Nov 7, 2013 at 12:27
  • @PreciousTijesunimi Is SystemRoot set correctly ("echo %SystemRoot%")? Nov 7, 2013 at 12:28
  • There is a gap on the second line:`%SYSTEMROOT%\Syst‌​e m32\WindowsPowerShell\v1.0` between the Syste and the m. You maybe should fix that.
    – Christian
    Nov 7, 2013 at 12:35

6 Answers 6

5

You say that when you type set path in a command prompt the path also contains PATH=%systemroot%\system32. If this is the case your %systemroot% does not get expanded to C:\Windows (or other real Windows-directory) when starting cmd.exe.

You can check your registry in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. All the names containing values with % characters (e.g. windir, temp, path and comspec) should be of type REG_EXPAND_SZ (and not REG_SZ) or the variable won't be expanded.

You should also check HKEY_CURRENT_USER\Environment if path is of type REG_EXPAND_SZ.

1
  • Upvote because this is a very good point and it fixes the real cause. Nov 7, 2013 at 12:37
2

Maybe the environment variables aren't set the right way:

  1. Right click ComputerPropertiesAdvanced System SettingsAdvanced (tab) → Environment Variables…
  2. In System variables, double-click on Path (or single-click, and click on Edit…) to examine (and, if necessary, edit) the variable.
  3. You have to make sure that these directories are defined in the Path variable:

    C:\WINDOWS\system32;C:\WINDOWS
    
7
  • This is only true if windows is installed to C:\windows. The correct (out-of-the-box) setting is %SystemRoot%\system32. Nov 7, 2013 at 12:30
  • Wow!!!. Thanks, I added the path to it and its now working perfectly
    – user264958
    Nov 7, 2013 at 12:31
  • 1
    @PreciousTijesunimi Glad I could help. You may accept the answer, so that other people can find the solution easier. :)
    – Christian
    Nov 7, 2013 at 12:32
  • @PreciousTijesunimi "%SystemRoot%\system32" is in your path, so please check %SystemRoot% - if it is wrong, then it should be set correctly and not a workaround with adding C:\windows\system32. Nov 7, 2013 at 12:33
  • @WernerHenze Those were there before and were not wrong but the commands were still not working. I added what is in the answer and they are now working
    – user264958
    Nov 7, 2013 at 12:36
1

The path is now managed by Windows 7 and not the autoexec.bat or autoexec.nt files. To change the system environment variables, follow the below steps.

From the desktop, right-click My Computer and click Properties. In the System Properties window, click on the Advanced tab. In the Advanced section, click the Environment Variables button. Finally, in the Environment Variables window (as shown below), highlight the Path variable in the Systems Variable section and click the Edit button. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below.

This is the default PATH environment variable setting on fresh install of Windows 7

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
0

After editing the variable PATH a trillion times, I had to correct the variable pathtext to read .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC instead of COM;EXE;BAT;CMD;VBS;VBE;JS;JSE;WSF;WSH;MSC. The difference the was the . (period) in front of the extensions. Wow!

0

The problem is environmental variable ,Solve the problem as following steps if path is not exist C:\Windows\System32 in environmental variable add in environmental variable C:\Windows\System32 then reboot your machine.am sure you will get solution

0

Just to add on to above mentioned comment from DavidPostill and user470866!

I ran into the same problem and looking into the PATH variable checked if the default values are there! e.g.: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

However, I noticed that the PATH variable was not starting with them but with some Java and Oracle references, hence I cut and copied the default one to the beginning of the line, e.g.: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\ in the beginning followed by all other stuff which was added by installed programs and saved and all of a sudden all my failing commands in CMD started working again.

Just an idea if anyone runs into this - apparently the order of the values in the PATH variable matters.

Thank you all for your guidance - it was extremely helpful!

You must log in to answer this question.