Hi,
Does anyone have a easy way to add a path to the PATH env. variable on a remote computer?
I know it’s a registry entry, and I use psexec with a .reg file to set remote registry entries, but now I have to append a setting to an existing entry, meaning I have to read somehow the entry and then append to it?
Does anyone have a solution for this? maybe not through the registry entries?
Thanks,
NirS
Hi NirS,
You can do this using WMI, you will need to create a ‘Run Script’ action with the following script:
var ComputerName = “machine”; // The remote machine to connect to
var User = “username”; // The username
var Pass = “password”; // The password
var NewVariable = “C:\SomeDir”; // Value to append to the PATH Variable *Slashes must be escaped
var objLocator = new ActiveXObject(“WbemScripting.SWbemLocator”);
var WMIObj = objLocator.ConnectServer(ComputerName,"/root/cimv2", User, Pass);
var Variables = WMIObj.ExecQuery(“SELECT * FROM Win32_Environment WHERE Name=‘PATH’ AND SystemVariable=‘True’”);
var FoundVar = new Enumerator(Variables)
var Item;
for(; !FoundVar.atEnd(); FoundVar.moveNext())
{
Item = FoundVar.item();
var ExistingPath = Item.VariableValue
ExistingPath = ExistingPath + “;” + NewVariable;
Item.VariableValue = ExistingPath;
Item.Put_();
}
Paul.
And if you want to do it manually you can use the standard regedit tool -> File menu | Connect Network Registry…
.t8
Thanks Paul very much!
That did the trick…