Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

RunWait not actually waiting?

$
0
0
Hello,

my script uses a custom URL. I want my program to auto-register it, if it is not registered yet.
This needs admin rights, so i chose to build a seperate executable which requires admin. So, the main script doesn't need admin rights on every launch.


[ autoit ]      
Func checkHandlerReg()    $prot = StringTrimRight($protocolString,3)    $reg = RegRead("HKEY_CLASSES_ROOT\"&$prot&"\shell\open\command","")    $handlerPath = $rootDir&"\bin\URL_handler.exe"    If Not StringInStr($reg,$handlerPath) Then       RunWait($rootDir&"\bin\regHandler.exe")    EndIf    Sleep(100)    $reg = RegRead("HKEY_CLASSES_ROOT\"&$prot&"\shell\open\command","")    If Not StringInStr($reg,$handlerPath) Then       MsgBox(4096,$PRODUCTNAME,"Error: Could not register URL-Handler!")       Exit    EndIf EndFunc


My problem:
You might have noticed the Sleep command. If i omit it, the following RegRead returns an empty String and my error MsgBox appears.
The RegWrite which regHandler.exe executes, works every time, The following RegRead is executed too early.

If i replace the RunWait with:
[ autoit ]      
#RequireAdmin RegWrite("HKEY_CLASSES_ROOT\"&$prot&"\shell\open\command","","REG_SZ",""""&$rootDir&"\bin\URL_handler.exe"" ""%1""")

Then omitting Sleep() works flawlessly.

Any idea?

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>