PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.

Running scripts from Standby?

 
 
=?Utf-8?B?TWljaGFlbA==?=
Guest
Posts: n/a
 
      20th Jan 2005
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?

 
Reply With Quote
 
 
 
 
Torgeir Bakken \(MVP\)
Guest
Posts: n/a
 
      20th Jan 2005
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...ementevent.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/scr...r/default.mspx
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWljaGFlbA==?=
Guest
Posts: n/a
 
      20th Jan 2005
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...ementevent.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/scr...r/default.mspx
>

 
Reply With Quote
 
Torgeir Bakken \(MVP\)
Guest
Posts: n/a
 
      21st Jan 2005
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/scr...r/default.mspx
 
Reply With Quote
 
=?Utf-8?B?TWljaGFlbA==?=
Guest
Posts: n/a
 
      21st Jan 2005
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/scr...r/default.mspx
>

 
Reply With Quote
 
New Member
Join Date: Mar 2007
Posts: 2
 
      20th Mar 2007
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 :-)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: For a website, are Excel scripts better than other programming language scripts? Tim Williams Microsoft Excel Programming 10 31st May 2009 05:11 AM
GP Logon Scripts vs Legacy Logon Scripts? Gerry Hickman Microsoft Windows 2000 Group Policy 0 10th Jul 2006 09:41 PM
logon scripts :- i can't seem to be able to define logon scripts =?Utf-8?B?bWljaGFlbC5u?= Windows XP Security 1 23rd Mar 2005 02:53 PM
Prevent changes made by VBA scripts from triggering "ON CHANGE" scripts E. Jordan Microsoft Access VBA Modules 1 29th Oct 2003 08:25 PM
can't view scripts (i.e. credit card scripts, javascripts, etc.) Mikey Windows XP Internet Explorer 1 15th Aug 2003 12:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:10 AM.