Jump to content

System Enviroment Path


craigey1
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

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()

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.

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

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...