我在%PATH%变量中添加了一些路径.而这条新路径(包括这条路径中的工具)工作正常.
可以使用CMD运行该路径中的工具而不会出现任何问题.
但是,一旦从ms windows services.msc作为服务运行相同的工具,它就说没有这样的工具.因此,由于某种原因,%PATH%变量未针对“本地系统”帐户进行更新.
我发现可以通过以下方式访问此帐户CMD:
psexec -i -s cmd.exe
事实上,我发现CMD以这种方式运行,PATH变量没有必要的工具路径.但我不能编辑它;我使用set或setx但在“本地系统”帐户的%PATH%中仍然没有可见的更改.
您需要重新启动Windows.
在重新启动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.