通过Powershell为另一个用户设置环境变量 [英] Setting a Environment Variables via Powershell for another User
问题描述
我正在尝试从管理员用户ABC的Powershell设置用户XYZ的环境变量。我正在使用Start-Process来启动用户XYZ的功能,但无法捕获输出。所有这些过程都需要用Java来完成。
I am trying to set the environment variables of a user XYZ from the powershell of admin user ABC. I am using Start-Process to launch the powershell of user XYZ but i am not able to capture the output. All this process needs to be done in Java.
有人可以帮我吗?
感谢
Ajax
Thanks Ajax
推荐答案
在此TechNet文章上进行检查: https://technet.microsoft.com/zh-cn/library/ff730964.aspx
Check this TechNet article on it: https://technet.microsoft.com/en-us/library/ff730964.aspx
基本上,您将需要在计算机范围内使用.NET方法对其进行设置:
Basically, you're going to want to set it using the .NET method at the machine scope:
[环境]: :SetEnvironmentVariable( TestVariable,测试值,机器)
您需要重新启动Powershell会话才能创建新的环境变量后可以访问它。
You'll need to restart your Powershell session to be able to access the new environment variable after creating it.
这篇关于通过Powershell为另一个用户设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!