Sign in to follow this  
Followers 0
Secondlaw

stringinsert

8 posts in this topic

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)

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 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 *

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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 & $CurrentPath

EndIf

If checkstr2 == 0 then

$NewPath = $AddtoPath2 & $NewPath

EndIf

Regwrite ("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?

Share this post


Link to post
Share on other sites

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


[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

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 *

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by Secondlaw

Share this post


Link to post
Share on other sites

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=debugger

http://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 *

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