Running scripts from Standby?

Discussion in 'Windows XP General' started by Guest, Jan 20, 2005.

  1. Guest

    Guest 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?
     
    Guest, Jan 20, 2005
    #1
    1. Advertisements

  2. Michael wrote:

    > 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


    --
    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
     
    Torgeir Bakken \(MVP\), Jan 20, 2005
    #2
    1. Advertisements

  3. Guest

    Guest 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.

    "Torgeir Bakken (MVP)" wrote:

    > Michael wrote:
    >
    > > 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
    >
    >
    > --
    > 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
    >
     
    Guest, Jan 20, 2005
    #3
  4. Michael wrote:

    > 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


    --
    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
     
    Torgeir Bakken \(MVP\), Jan 21, 2005
    #4
  5. Guest

    Guest Guest

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

    "Torgeir Bakken (MVP)" wrote:

    > Michael wrote:
    >
    > > 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
    >
    >
    > --
    > 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
    >
     
    Guest, Jan 21, 2005
    #5
  6. Guest

    ejepsen

    Joined:
    Mar 20, 2007
    Messages:
    2
    Likes Received:
    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 :)
     
    ejepsen, Mar 20, 2007
    #6
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    1
    Views:
    464
    Guest
    Mar 23, 2005
  2. Mikey
    Replies:
    1
    Views:
    421
    Rob Parsons
    Aug 15, 2003
  3. E. Jordan
    Replies:
    1
    Views:
    375
    Guest
    Oct 29, 2003
  4. Gerry Hickman

    GP Logon Scripts vs Legacy Logon Scripts?

    Gerry Hickman, Jul 10, 2006, in forum: Microsoft Windows 2000 Group Policy
    Replies:
    0
    Views:
    444
    Gerry Hickman
    Jul 10, 2006
  5. Tim Williams
    Replies:
    10
    Views:
    576
    Tim Williams
    May 31, 2009
Loading...

Share This Page