Issue
here is the path before edit:
echo %path%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;
Then i use cmd order path=%path%C:\Test;
to add a new root to path.
After that, i echo %path%
again, and i got this:
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps;C:\Test;
It looks good,Gight?.But when i go into system property.
I got this:
Obviously, the new root C:\Test
is not showing in the system property.
I want to know why and how to fix the problem.
Solution
To do what you were hoping to do, specifically appending to the existing System Environment %Path%
variable, this is how I'd recommend you do it:
From cmd
For /F "EOL=H Tokens=2,*" %G In ('%SystemRoot%\System32\reg.exe Query "HKLM\SYSTEM\CurrentControlset\Control\Session Manager\Environment" /V Path 2^>NUL') Do @%SystemRoot%\System32\setx.exe Path "%HC:\Test;" /M
From a batch-file
@For /F "EOL=H Tokens=2,*" %%G In ('%SystemRoot%\System32\reg.exe Query
"HKLM\SYSTEM\CurrentControlset\Control\Session Manager\Environment" /V Path
2^>NUL') Do @%SystemRoot%\System32\setx.exe Path "%%HC:\Test;" /M
Please note: to do this, you'll need to run your cmd/batch-file elevated, i.e. "Run as administrator". Also this is designed to add your new directory location, only if there is already non space content within that variables value, (if there isn't your system is already broken). You should also note that the new variable content will only be available for future cmd.exe
instances, not any currently running ones, (which were loaded prior to your change). If you wanted it available globally and local to the running session, you'd need to also include the separate command, Set "Path=%Path%C:\Test;"
Answered By - Compo Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.