steve8tch Posted June 28, 2004 Share Posted June 28, 2004 I was updating an old script - adding in the new line $data = RegRead("\\" & $PC & "\" & $key, $value) Seems to work well as long as the $PC is online and I have permissions to read the registry. The problem is if the target PC '$PC' is off line or I don't have permissions to read its registry then the RegRead function takes 30 seconds to error out and continue the script. I my old script I used to call up reg.exe to do the remote queries and then kill off the reg.exe process after a few seconds. ( If PC was online you would get a virtually instant return of data) My questions. Can Adlib be used to kill of the RegRead function once it has been called ? Can I use any other tricks to move the script on to the next line ? Do I need to move this question to the 'ideas' section to ask for a timeout value to be added to RegRead - eg RegRead ( "keyname", "valuename",timeout ) The problem is - with a list of 1000 PCs to get through - if 200 are off line for any reason - this adds 1.5 hours onto runtime !! eg RegRead ( "keyname", "valuename",timeout ) Link to comment Share on other sites More sharing options...
pekster Posted June 28, 2004 Share Posted June 28, 2004 I don't know if script execution is paused durring a RegRead call. I would assume it's not since the helpfile says nothing about it, so I believe I have a solution. If you start a 2nd instance of your script with command line paramaters for the PC, key, and value, you can have the AdLib kill the script if it doesn't find the value within 2 seconds, or whatever your limit is. If it does find it, just disable the AdLib detection, and change the AutoItWin title so that your main script can be aware that you found it. Here is an example: If $CmdLine[0] = 3 Then;handle the RegRead instance Global $time = 0 AdLibEnable("timer", 1000);one second timer to incriment and check $time $data = RegRead("\\" & $CmdLine[1] & "\" & $CmdLine[2], $CmdLine[3]) AdLibDisable();if we get this far, the command was valid AutoItWinSetTitle("RegRead: " & $data);inform main instance of our result WinWait("RegRead- data read");wait for main instance to read data Exit;quit EndIf Func timer() $time = $time + 1 If $time > 2 Then;this means more than 2 seconds have elapsed AutoItWinSetTitle("RegRead: timeout");return timeout result WinWait("RegRead- data read");wait for main instance to read data Exit;quit EndIf EndFunc ;NOTE: all text should be enclosed in double quotes if there are spaces $PC = '"<INSERT TEXT HERE>"' $key = '"<INSERT TEXT HERE>"' $value = '"<INSERT TEXT HERE>"' Run(@ScriptFullPath & " " & $PC & " " & $key & " " & $value) WinWait("RegRead:") $title = WinGetTitle("RegRead:") If StringRight($title, 7) = "timeout" Then ;a timeout occured, so do something about it Else ;valid RegRead command, so save the value: $RegValue = StringMid($title, 10, StringLen($title)) EndIf AutoItWinSetTitle("RegRead- data read");inform 2nd instance that data is read WinWaitNotActive("RegRead:");wait for 2nd instance to shut down AutoItWinSetTitle("AutoIt v3");reset title for future registry calls [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
sugi Posted June 28, 2004 Share Posted June 28, 2004 Far easier to script: check if a computer is online before trying to access its registry. In very rare cases when the computer was online while checking but got turned off before accessing the registry you'll still have this delay but even with 1000 PCs its unlikely you'll get that more than one time. Link to comment Share on other sites More sharing options...
CyberSlug Posted June 28, 2004 Share Posted June 28, 2004 You could try this script to check if a computer is online. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
steve8tch Posted June 28, 2004 Author Share Posted June 28, 2004 Thanks alot lads for your replies In other scripts I have written that go out on the network - I use a ping routine (similar to one suggested by @Cyberslug )- but the script I created to do most of the registry work didn't use this because there are loads of Unix boxes and other departmental boxes that I do not have permissions to assess - so even if I checked to see if they were online - I still needed a way of cutting short a registry query in order to make progress. It is really good to have the registry function built in to Aut3 - it is certainly far simpler to use - I will see if I can use @Petskers idea somehow. Thanks. Now how about a built in RegRead timeout value............... Link to comment Share on other sites More sharing options...
steve8tch Posted June 28, 2004 Author Share Posted June 28, 2004 Thanks alot lads for your replies In other scripts I have written that go out on the network - I use a ping rou 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