2

I'm using a command process in another program that for some odd reason does not have the system32 set in the path environment variable. I can use the %comspec% variable to get the path C:/windows/system32/cmd.exe, but I need to just have the folder by itself.

I am not overly familiar with command prompt programming; is there a way that I can just add the system32 (or equivalent) path programmatically?

Peter Noble
  • 675
  • 10
  • 21
Christian Boler
  • 151
  • 2
  • 17
  • See http://stackoverflow.com/questions/778135/how-do-i-get-the-equivalent-of-dirname-in-a-batch-file – Chelsea Urquhart Aug 29 '14 at 13:39
  • Personally, I'd try googling "Path Editor". Your quest is not clear. DO you just want to add the system32 directory to the path? – Magoo Aug 29 '14 at 13:45

3 Answers3

3

What do you mean programmatically? If you're refering to a variable, there is no standard variable for system32. However you could use %WINDIR%\system32 or %systemroot%\system32.

Peter Noble
  • 675
  • 10
  • 21
1

While it appears that there is no environment variable for obtaining the system32 folder (or its equivalent) on a system, I did find a solution involving string manipulation. The following block of code will add the folder where the cmd.exe path is located:

SET str=%ComSpec%
SET str=%str:cmd.exe=%
SET PATH=%PATH%;%str%
Badhan Sen
  • 617
  • 1
  • 7
  • 18
Christian Boler
  • 151
  • 2
  • 17
-2

It is very nice answer. i have tried and worked out. This problem comes with window7 OS probably.

    SET str=%ComSpec%
    SET str=%str:cmd.exe=%
    SET PATH=%PATH%;%str%
piet.t
  • 11,718
  • 21
  • 43
  • 52
Sundar
  • 1