cmd.exe not recognizing system32 in PATH

O

Owen Funkhouser

When I load cmd.exe and execute a file that exists in C:\WINDOWS\System32, I get
the following error:
'attrib' is not recognized as an internal or external command,
operable program or batch file.

C:\>path
PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\PROGRA~1\MICROS~2\Common\MSDev98\Bin;C:\PROGRA~1\MICROS~2\VC98\Bin;C:\PROGRA~1\MICROS~2\Common\Tools\WinNT;C:\PROGRA~1\MICROS~2\Common\Tools;C:\Program
Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft
Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual
Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin

C:\>echo %SystemRoot%
C:\WINDOWS

Now if I replace "%SystemRoot%\system32" with "C:\WINDOWS\system32", the
"attrib" command is recognized.

Why is my PATH variable not resolving other environment variables?
 
B

Bill James

Check this Registry key, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment, the Path value. If type is not REG_EXPAND_SZ that is your problem. If so, the easiest way to fix it is to double click the Path value, copy the path string to NotePad, delete the Path value then recreate it as the correct type pasting in the path string you previously saved. Before doing this kind of serious Registry editing, Best Safe Practice is to create a System Restore Point first.

--

Bill James
Microsoft MVP - Shell/User

Win9x VBScript Utilities » www.billsway.com/vbspage/
Windows Tweaks & Tips » www.billsway.com/notes_public/
 
T

Torgeir Bakken (MVP)

Owen said:
When I load cmd.exe and execute a file that exists in C:\WINDOWS\System32, I get
the following error:
'attrib' is not recognized as an internal or external command,
operable program or batch file.

C:\>path
PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\PROGRA~1\MICROS~2\Common\MSDev98\Bin;C:\PROGRA~1\MICROS~2\VC98\Bin;C:\PROGRA~1\MICROS~2\Common\Tools\WinNT;C:\PROGRA~1\MICROS~2\Common\Tools;C:\Program
Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft
Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual
Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin

Hi

As I see that you have variables surrounded with % in your path
environment output. that part of the path containing those will not
work, and the cause of the problem is that a rough install have
changed the Path entry in registry from REG_EXPAND_SZ to REG_SZ
(just as Bill James pointed out)

More about this issue here:
http://home.comcast.net/~stewartb/cmdprompt.html#6
 
A

Alex Nichol

Owen said:
When I load cmd.exe and execute a file that exists in C:\WINDOWS\System32, I get
the following error:
'attrib' is not recognized as an internal or external command,
operable program or batch file.

C:\>path
PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\PROGRA~1\MICROS~2\Common\MSDev98\Bin;C:\PROGRA~1\MICROS~2\VC98\Bin;C:\PROGRA~1\MICROS~2\Common\Tools\WinNT;C:\PROGRA~1\MICROS~2\Common\Tools;C:\Program
Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft
Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual
Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin

C:\>echo %SystemRoot%
C:\WINDOWS

Now if I replace "%SystemRoot%\system32" with "C:\WINDOWS\system32", the
"attrib" command is recognized.

Why is my PATH variable not resolving other environment variables?


I suspect because it has plain and simple got much too long. A lot of
those things have no business being in a general path, but should be in
the application concerned's own 'personal' item in the registry, at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
\AppPaths\packagename

where there should be a Path item in the right pane to include its own
section to add on.
 
O

Owen Funkhouser

That fixed it. Thanks!

Bill said:
Check this Registry key, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment, the Path value. If type is not REG_EXPAND_SZ that is your problem. If so, the easiest way to fix it is to double click the Path value, copy the path string to NotePad, delete the Path value then recreate it as the correct type pasting in the path string you previously saved. Before doing this kind of serious Registry editing, Best Safe Practice is to create a System Restore Point first.

--

Bill James
Microsoft MVP - Shell/User

Win9x VBScript Utilities » www.billsway.com/vbspage/
Windows Tweaks & Tips » www.billsway.com/notes_public/
 
O

Owen Funkhouser

Torgeir Bakken (MVP) said:
Hi

As I see that you have variables surrounded with % in your path
environment output. that part of the path containing those will not
work, and the cause of the problem is that a rough install have
changed the Path entry in registry from REG_EXPAND_SZ to REG_SZ
(just as Bill James pointed out)

More about this issue here:
http://home.comcast.net/~stewartb/cmdprompt.html#6

That fixed it. Thanks!
 
O

Owen Funkhouser

Alex said:
I suspect because it has plain and simple got much too long.

The PATH length is quite fine. But a good suggestion. Thanks.
A lot of
those things have no business being in a general path, but should be in
the application concerned's own 'personal' item in the registry, at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
\AppPaths\packagename
where there should be a Path item in the right pane to include its own
section to add on.

I agree. By the way, have you ever loaded .NET Command Prompt? The PATH in
that shell is longer than the one above and it works just fine.

Bill's and Torgeir's solution fixed the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top