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.
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:
Then omitting Sleep() works flawlessly.
Any idea?
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?