简体   繁体   中英

How to change %PATH% value for “local system” account in MS Windows?

I am struggling with setting up %PATH% variable in MS Windows for "local system" account.

I have added some paths into %PATH% variable. And that new path (including tools which are in this path) is working fine. Tools from that path can be run using CMD with no issues. But once the same tool is to be run from ms windows services.msc as a service, it says that there is no such tool. Hence for some reason, %PATH% variable was not updated for "local system" account.

I found that access to this account CMD can be done with as follow:

psexec -i -s cmd.exe

Indeed I found that CMD run in this style and PATH variable doesn't have needed path to tools. But I can't edit it; I use either set or setx but still no changes visible in %PATH% from "local system" account.

I want to set the %PATH% variable in MS Windows for "local system" account.

You need to restart Windows.


Changes that you make to environment variables do not affect services that run under the Local System account until you restart Windows

If you update environment variables or add new environment variables, you must restart the computer before the changes that you make affect services that run under the Local System account.

This behavior occurs because services that run under the Local System account inherit their environment from the Services.exe process. The Services.exe process receives the environment settings for the Local System account when Windows starts. Because the Services.exe process does not use Windows Messaging, when it receives messages that indicate that a value has changed after Windows starts, the Services.exe process does not update its environment settings. You cannot force a service that is running to acknowledge a dynamic change to the environment of the Local System account.

Source Changes that you make to environment variables do not affect services that run under the Local System account until you restart Windows

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM