craigey1 Posted February 14, 2007 Posted February 14, 2007 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
Moderators SmOke_N Posted February 14, 2007 Moderators Posted February 14, 2007 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.ThanksIf 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.
therks Posted February 14, 2007 Posted February 14, 2007 Maybe he means the PATH environment variable (which can be read/modified with EnvGet and EnvSet). My AutoIt Stuff | My Github
MHz Posted February 14, 2007 Posted February 14, 2007 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now