run loop for 2 minutes then end

Author Message
spectrum1

  • Total Posts : 7
  • Scores: 0
  • Reward points : 0
  • Joined: 12/5/2011
  • Status: offline
run loop for 2 minutes then end Monday, January 23, 2012 3:44 PM (permalink)
0
Hi,
We are having an issue with our login script, we have software install after users logon which makes a change to the registry. We need our script to detect changes in registry and run a software registry update. How can we have this script loop / run every 5 seconds for 2 minutes, polling the registry for changes? So registry changes which are made after login can be picked up by this script.
 
Const HKEY_CURRENT_USER = &H80000001
 
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & _
   strComputer & "\root\default:StdRegProv")
 
strKeyPath = "Software\Hewlett-Packard\network\Lex"
strValueName = "bbnv"
objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName, strValue
 
If IsNull(strValue) Then
WshShell.Run "regedit /S X:\disableaddins.reg", 0, True
Else 
WshShell.Run "regedit /S X:\installaddins.reg", 0, True
End If
 
#1
    59cobalt

    • Total Posts : 981
    • Scores: 91
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: offline
    Re:run loop for 2 minutes then end Monday, January 23, 2012 11:54 PM (permalink)
    0
    You can achieve that with a loop like this:
    endTime = DateAdd("n", 2, Now)
    strValue = Null
    Do While Now <= endTime And IsNull(strValue)
     WScript.Sleep 5000
     ' check registry
    Loop

     
    #2
      spectrum1

      • Total Posts : 7
      • Scores: 0
      • Reward points : 0
      • Joined: 12/5/2011
      • Status: offline
      Re:run loop for 2 minutes then end Tuesday, January 24, 2012 11:09 AM (permalink)
      0
      Perfect, worked well. Thank you!
       
      #3
        59cobalt

        • Total Posts : 981
        • Scores: 91
        • Reward points : 0
        • Joined: 7/17/2011
        • Status: offline
        Re:run loop for 2 minutes then end Wednesday, January 25, 2012 1:55 AM (permalink)
        0
        You're welcome.
         
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.9