Sign in to follow this  
Followers 0
RebolTutorial

How to add to path environment variable with autoit ?

2 posts in this topic

I can use rebol to get the value of path environment variable but I cannot modify it so I'd like to use autoit to do so. Is it possible ? If yes can you give me a sample code or a clue ? thanks.


Rebol Tutorial: Join the Rebolution!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I can use rebol to get the value of path environment variable but I cannot modify it so I'd like to use autoit to do so. Is it possible ? If yes can you give me a sample code or a clue ? thanks.

Yes, it is possible :blink:. Take a look to help file; EnvGet, EnvSet & EnvUpdate.

Edit: Well, using EnvSet to set an environment variable will made this "add" available to programs that AutoIt spawns (Run, RunWait). Once AutoIt closes, the variables will cease to exist.

So, if you want to make the change permanent could use something like this:

$key = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
$val = "PATH"
$PATH = RegRead($key, $val)

$sAddThisPath = "C:\my new path\"
$PATH = $PATH & ";" & $sAddThisPath

RegWrite($key,$val,"REG_EXPAND_SZ",$PATH)
EnvUpdate()

Cheers,

sahsanu

Edited by sahsanu
1 person likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0