Jump to content

Recommended Posts

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 post
Share on other sites

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

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

;NOTE: all text should be enclosed in double quotes if there are spaces
$key = '"<INSERT TEXT HERE>"'
$value = '"<INSERT TEXT HERE>"'

Run(@ScriptFullPath & " " & $PC & " " & $key & " " & $value)
$title = WinGetTitle("RegRead:")
If StringRight($title, 7) = "timeout" Then
 ;a timeout occured, so do something about it
 ;valid RegRead command, so save the value:
  $RegValue = StringMid($title, 10, StringLen($title))
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 post
Share on other sites

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 post
Share on other sites

Thanks alot lads for your replies :D

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.


Now how about a built in RegRead timeout value...............

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...