Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

windows

cmd

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.

like image 496
user2273663 Avatar asked Aug 18 '15 09:08

user2273663


1 Answers

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

like image 83
DavidPostill Avatar answered Nov 17 '22 10:11

DavidPostill