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?
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.
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%
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%
Related
I'm working in Windows 10 on a rails project and want to open up the devise gem to have a look. I'm running bundle open devise, which gives me the following
C:\Users\MyName\Documents\MyRailsProj>bundle open devise
Could not run 'C:Program FilesMicrosoft VS CodeCode.exe C:/Ruby22/lib/ruby/gems/2.2.0/gems/devise-4.4.1'
I've set the environment variable EDITOR to C:\Program Files\Microsoft VS Code\Code.exe in my system, which is the correct location of VS Code on my system. I've also tried setting it to point to sublime3, which has the same result.
I'm guessing I've just set this variable incorrectly, but I don't know how bundle open expects the EDITOR or BUNDLER_EDITOR to be set other than to the path of the program I want to use to open the gem. Any ideas why I can't open the gem?
edit:
I can totally just use bundle show devise so see the gem's location and go find and open it in vs code all I want, but I do also want to know how to use the EDITOR environment variable properly, so I think the question still has merit if anyone has any ideas.
It looks like bundle is treating the environment variable as an escaped string, and so all the path separators are being lost. In addition, it also might not be handling spaces correctly.
However, you might not need the path at all.
If you can open the editor just by typing "Code" at a command prompt, just set EDITOR to
code
Otherwise, instead of setting it to
C:\Program Files\Microsoft VS Code\Code.exe
try
C:\\Program\ Files\\Microsoft\ VS\ Code\\Code.exe
or
"C:/Program Files/Microsoft VS Code/Code.exe"
I was trying to set my path using setx /M PATH "%PATH%;C:\Python27\Scripts" as given in an answer How do I add to the Windows PATH variable using setx? Having weird problems. However this appears to remove all my current path setting and the new one doesnt work either. Is there any way I can revert back to my old settings?
I don't know why my system is only detecting environment variable of system and not user.
For instance, when I put "C:\Program Files\Java\jdk1.8.0_25\bin" as first environment variable in user environment variable , I was not able to run "javac" command.
But when I pasted it to system variable it started working.
I know about the dependency issues if I would have placed the path in user variable at the end so I put it at the beginning but still it didn't work..
I searched but found no real solution except dependency issue if I put it at the end.
Have you restarted the CMD?
Maybe you have to logoff & logon to refresh the user variables.
It least on my Windows 7 I have the same behavior, new user variable is not available.
I have a problem assessing my advanced settings of my computer, anytime i get to the properties of my computer it freezes and vanishes, I decided to set my path through the command prompt. Though the lines below works. Its just temporal and the path is unset immediately i close the running command prompt,
set path=%path%;C:\python27
I am just wondering why my computer's property panel vanishes.
Any others ways to set the environment variables permanent?
try using setx PATH "%PATH%;C:\python27"
Note that u need to close the current cmd window, after executing this command as the changes will reflect in newer instances only.
I have just installed an app which overwrote my $PATH variable... so now, a bunch of stuff will not work. While I have a full backup, I am hoping that there is an easier approach than to restore, get the PATH, the "roll it forward" again.
Is there a location in the windows registry (or anywhere else) that stores an older $PATH setting?
Thanks,
GS
If anyone is interested, I found the answer...
using REGEDIT, it is under
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment or
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Session Manager\Environment
In my case, it was under HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002...
GS
type in cmd:
set path=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
above code will set the path temporarily. To set permanently, add %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\; to System Properties -> Advanced System Settings -> Environment Variables