Archived from groups: microsoft.public.windowsxp.general (More info?)
I'm looking for a way to run a batch or program after a XP machines wakes
from standby. In this case I want to force a VPN to reconnect after the
machine resumes from standby.
Archived from groups: microsoft.public.windowsxp.general (More info?)
John Steele wrote:
> I'm looking for a way to run a batch or program after a XP
> machines wakes from standby. In this case I want to force a
> VPN to reconnect after the machine resumes from standby.
>
Hi,
You can use the WMI class Win32_PowerManagementEvent to detect a
standby event.
Try the vbscript below and see what you get as result (put it in a
file with .vbs as file extension name).
When you have adjusted the VBScript to your requirements, I suggest you
set it to start as part of the user logon, e.g. by adding a new entry
to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\
registry key, and using a launch command something like this:
wscript.exe "C:\Scripts\LaunchAfterStandby.vbs"
A vbscript example (will loop forever until terminated):
'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell" )
Set colMonitoredEvents = GetObject("winmgmts:" )._
ExecNotificationQuery("Select * from Win32_PowerManagementEvent" )
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Case 7
' To run a batch file hidden, you can do like this:
'oShell.Run """C:\My scripts\mybatch.bat""", 0, False
' Launch Notepad
oShell.Run "Notepad.exe", 1, False
MsgBox "Resuming from suspend, notepad started", _
vbInformation + vbSystemModal, "Suspend"
You are about to answer a thread that has been inactive for more than 6 months. If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.