Secondlaw Posted November 20, 2006 Share Posted November 20, 2006 Hi everyone... I was trying to do something rather simple here but I'm a little confused as to my string insert is not working properly. Can someone make a recommendation? Thanks $CurrentPath = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","path") $AppPath = ("C:\apps\bin\;C:\apps\Bin2;") ;msgbox(4096, "Test", $CurrentPath, 5) $NewPath=func_StringInsert ($AppPath, $CurrentPath, 1) Regwrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_SZ", $NewPath) Link to comment Share on other sites More sharing options...
/dev/null Posted November 20, 2006 Share Posted November 20, 2006 (edited) Hi everyone... I was trying to do something rather simple here but I'm a little confused as to my string insert is not working properly. Can someone make a recommendation? why use _StringInsert() when you just want to concatenate two strings?? $CurrentPath = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","path") $AppPath = ("C:\apps\bin\;C:\apps\Bin2;") $NewPath= $AppPath & $CurrentPath ; <<== CHANGED THIS !! Regwrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_SZ", $NewPath) Cheers Kurt Edited November 20, 2006 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Secondlaw Posted November 20, 2006 Author Share Posted November 20, 2006 why use _StringInsert() when you just want to concatenate two strings?? $CurrentPath = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","path") $AppPath = ("C:\apps\bin\;C:\apps\Bin2;") $NewPath= $AppPath & $CurrentPath ; <<== CHANGED THIS !! Regwrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_SZ", $NewPath) Cheers Kurt I knew there had to be an easier way! Thanks! Link to comment Share on other sites More sharing options...
Secondlaw Posted November 20, 2006 Author Share Posted November 20, 2006 I knew there had to be an easier way! Thanks!Ok, I've decided to modify this script a little and can't figure one more thing out...$CurrentPath = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","path")$AddtoPath1 = ("C:\Oracle8i_home\bin\;")$AddtoPath2 = ("C:\Orant\Bin;")checkstr = StringInstr ($CurrentPath, $AddtoPath1)checkstr2 = StringInstr ($CurrentPath, $AddtoPath2)msgbox(4096, "Test", $checkstr, 5)If CheckStr == 0 then $NewPath = $AddtoApp1 & $CurrentPathEndIfIf checkstr2 == 0 then $NewPath = $AddtoPath2 & $NewPathEndIfRegwrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_SZ", $NewPath)for some reason, 'stringinstr' from above isn't working. What am I doing wrong now? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 20, 2006 Moderators Share Posted November 20, 2006 What's the output of $addtoPath1 and $addtopath2 and $currentpath? You also have a semicolon as the last character of the addtopath(s)... I doubt that's in the output of the $currentpath 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 More sharing options...
/dev/null Posted November 20, 2006 Share Posted November 20, 2006 for some reason, 'stringinstr' from above isn't working. What am I doing wrong now? StrinInStr() works fine, but your script is full of errors! $CurrentPath = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","path") $AddtoPath1 = ("C:\Oracle8i_home\bin\;") $AddtoPath2 = ("C:\Orant\Bin;") $checkstr = StringInstr ($CurrentPath, $AddtoPath1); <<== CHANGED THIS (missing $) $checkstr2 = StringInstr ($CurrentPath, $AddtoPath2); <<== CHANGED THIS (missing $) msgbox(4096, "Test", $checkstr, 5) $NewPath = $CurrentPath; <<== ADDED THIS If $checkstr == 0 then $NewPath = $AddtoPath1 & $NewPath ; <<== CHANGED THIS (2 changes) EndIf If $checkstr2 == 0 then $NewPath = $AddtoPath2 & $NewPath EndIf Regwrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_SZ", $NewPath) __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Secondlaw Posted November 20, 2006 Author Share Posted November 20, 2006 (edited) Attention to detail! I've been using Winbatch for years and am trying to learn a bit about AutoIt. This is my first Auto-it script. The languages appear to be very similar with a few minor changes here and there. One of them is the "$" before my variables. Thanks a lot for your assistance! One thing I will mention, and it's possible I'm missing it, but is there a debug feature? That would be extremely helpful! Edited November 20, 2006 by Secondlaw Link to comment Share on other sites More sharing options...
/dev/null Posted November 20, 2006 Share Posted November 20, 2006 One thing I will mention, and it's possible I'm missing it, but is there a debug feature? That would be extremely helpful!here are two ways to do it.http://www.autoitscript.com/forum/index.ph...amp;hl=debuggerhttp://www.autoitscript.com/forum/index.ph...amp;hl=debugger __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
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