Sign in to follow this  
Followers 0
craigey1

System Enviroment Path

4 posts in this topic

Is there any way to edit the PATH variable using autoit?

I've tried searching, but there are lots of threads with the words path, system & variable in them!

I just need to do a simple replace on the jdkpath, but obviuosly I need to beable to read & write to it.

Thanks

Share this post


Link to post
Share on other sites



Is there any way to edit the PATH variable using autoit?

I've tried searching, but there are lots of threads with the words path, system & variable in them!

I just need to do a simple replace on the jdkpath, but obviuosly I need to beable to read & write to it.

Thanks

:whistle:

If you mean a file path, look at _PathSplit()


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Maybe he means the PATH environment variable (which can be read/modified with EnvGet and EnvSet).

Share this post


Link to post
Share on other sites

It may look like this for a permanent change

Global $join, $path, $split
$path = RegRead('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path')
If Not @error Then
    $split = StringSplit($path, ';')
    If Not @error Then
        For $i = 1 To $split[0]
            StringReplace($split[$i], 'jdkpath', 'new_jdkpath') ; alter jdkpath path
            $join &= $split[$i] & ';'
        Next
        If StringRight($join, 1) = ';' Then $join = StringTrimRight($join, 1)
        If RegWrite('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', 'REG_EXPAND_SZ', $join) Then
            MsgBox(0, 'Path Changed', $join)
        EndIf
    EndIf
EndIf

:whistle:

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