Jump to content

How to add to path environment variable with autoit ?


Recommended Posts

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...