Take the 2-minute tour ×

Wondering what tools are available to remotely edit (find and replace actually) the PATH environment variable on all users workstations across the enterprise? We do use SCCM (formerly SMS), but I don't know if that provides the capability to do that. Is this possible with Powershell maybe?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

I'd caution you about doing what Nick O'Neil suggests insofar as just blindly overwriting the PATH variable in the registry of all your client computers is likely to cause problems.

A quickie one-liner for a search-and-replace on a literal string in PowerShell would be (long line wrapped for readability-- this is all a single line):

Set-ItemProperty "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path -value ( (Get-ItemProperty "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path).Path -replace "OLD STRING", "NEW STRING")

You could run that as an Active Directory Startup Script on the affected computers. You could even get fancy and put some kind of flag in the registry (join the computer to a group that's denied rights to apply the GPO again, etc) to make the script only run once per computer.

share|improve this answer
I can't believe I wrote something in PowerShell. I feel sorta dirty. >smile< –  Evan Anderson Oct 27 '10 at 20:53

Editing the registry could be one way of doing this, navigate to HKLM\System\Current Control Set\Control\Session Manager\Environment

If you save this registry change you could then deploy it across the organization via a group policy.

share|improve this answer

Your Answer


