# Changing remote environment varables

**URL:** https://www.finalbuilder.com/forums/t/changing-remote-environment-varables/205
**Category:** Discussion
**Created:** [September 21, 2006, 3:03am UTC](https://www.finalbuilder.com/forums/t/changing-remote-environment-varables/205 "2006-09-21T03:03:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nirsilgi](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/a6a055/32.png) [@nirsilgi](https://www.finalbuilder.com/forums/u/nirsilgi)
#### Post date: [September 21, 2006, 3:03am UTC](https://www.finalbuilder.com/forums/t/changing-remote-environment-varables/205/1 "2006-09-21T03:03:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [September 22, 2006, 1:37am UTC](https://www.finalbuilder.com/forums/t/changing-remote-environment-varables/205/2 "2006-09-22T01:37:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [September 22, 2006, 1:40am UTC](https://www.finalbuilder.com/forums/t/changing-remote-environment-varables/205/3 "2006-09-22T01:40:38Z")

</div>

And if you want to do it manually you can use the standard regedit tool -\> File menu | Connect Network Registry…  
  
.t8

---

<div class="post-metadata">

### Author: ![nirsilgi](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/a6a055/32.png) [@nirsilgi](https://www.finalbuilder.com/forums/u/nirsilgi)
#### Post date: [September 25, 2006, 5:59am UTC](https://www.finalbuilder.com/forums/t/changing-remote-environment-varables/205/4 "2006-09-25T05:59:06Z")

</div>

Thanks Paul very much!   
That did the trick…
