Running scripts from Standby?

G

Guest

Does anyone know if it's possible to run scripts (or *.exe's) when you go
into Standby and out of Standby?

The application is I have a small *.exe which sends a serial command out of
the RS232 to a projector to turn the projector on (and I have another *.exe
to turn the projector off when I turn the PC off). The *.exe's work fine when
going in and out of Shurdown. However, the problem is I cannot use the XP MCE
Remote Control to turn the PC on (for obvious reasons) -- the remote can only
be used for Standby, but then I'm not able to run my *.exe's. Any ideas?
 
T

Torgeir Bakken \(MVP\)

Michael said:
Does anyone know if it's possible to run scripts (or *.exe's) when you go
into Standby and out of 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).

Win32_PowerManagementEvent WMI class
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_powermanagementevent.asp


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

Select Case objLatestEvent.EventType

Case 4
oShell.Run "Calc.exe", 1, False
MsgBox "Entering suspend, Calc started", _
vbInformation + vbSystemModal, "Suspend"

Case 7
oShell.Run "Notepad.exe", 1, False
MsgBox "Resuming from suspend, notepad started", _
vbInformation + vbSystemModal, "Suspend"

Case 11
MsgBox "OEM Event happened, OEMEventCode = " _
& strLatestEvent.OEMEventCode

Case 18
MsgBox "Resume Automatic happened"

End Select
Loop
'--------------------8<----------------------


WSH 5.6 documentation (local help file) can be downloaded from here
if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
 
G

Guest

Torgeir, Thanks. I haven't studied your reply too deply, but if I create a
*.vbs script, what system directory/folder do I put it in such that XP will
automatically execute it when I put the system in and out of (ACPI) Standby?
Thanks for any hints. Mike.
 
T

Torgeir Bakken \(MVP\)

Michael said:
Torgeir, Thanks. I haven't studied your reply too deply, but if I create a
*.vbs script, what system directory/folder do I put it in such that XP will
automatically execute it when I put the system in and out of (ACPI) Standby?
Thanks for any hints. Mike.
Hi

I suggest you set it to start as part of the user logon.

E.g. put the script (or a shortcut to script) in the Startup
folder for "All Users":

C:\Documents and Settings\All Users\Start Menu\Programs\Startup
 
G

Guest

Good enough. I'll give it a try. Thanks.

Torgeir Bakken (MVP) said:
Hi

I suggest you set it to start as part of the user logon.

E.g. put the script (or a shortcut to script) in the Startup
folder for "All Users":

C:\Documents and Settings\All Users\Start Menu\Programs\Startup


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
 
Joined
Mar 20, 2007
Messages
2
Reaction score
0
I have the same issue and have attemted to do the same as recommeded above but without any luck.

Michael: Did you find a solution to this? (I know it's been quite a while :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top