Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Place PC in Standby Mode

Status
Not open for further replies.

Dryheat

Technical User
Oct 18, 2004
62
US
I searched this and another thread and did not find a satisfactory resolution.

I am working on a script that I can assign to a scheduled task in Windows XP Pro. The scheduled task will wake the PC out of standby mode and execute my desired program updates. This much has been completed and all that remains is some method to programatically place the PC back in Standby mode when the updates are completed. I can not rely on the power management settings to place it on standby after a predetermined period of time due to the unknown amount of time it will take to complete all program updates.
Thanks for your assistance.
 
[1] Due to personal involvement in a recent thread of api calling vba pass-through (ref I can offer you a script in the same spirit with a lower-level touch, using setsuspendstate api call, so that other members can have another chance to exercise their mind on this method. This is how you do.
[tt]
dim scode,oxl,owb,omod,nrtn

scode="Declare Function SetSuspendState Lib ""Powrprof.dll""" & _
"Alias ""SetSuspendState""(ByVal Hibernate As Boolean, ByVal ForceCritical As Boolean, " & _
"ByVal DisableWakeEvent As Boolean) As Integer" & vbcrlf

scode=scode & "function set_suspendstate () As Integer" & vbcrlf
scode=scode & "set_suspendstate=SetSuspendState(false,false,false)" & vbcrlf
scode=scode & "end function"

set oxl=createobject("excel.application")
set owb=oxl.workbooks.add
set omod=owb.vbproject.vbcomponents.add(1)
omod.codemodule.addfromstring scode
on error resume next
nrtn=oxl.run("set_suspendstate")
on error goto 0
set omod=nothing
owb.saved=true
owb.close
set owb=nothing
oxl.quit
set oxl=nothing

[green]'note: The instance will be cleaned up automatically upon wakeup, so no worry here.[/green]
[/tt]
It is kept completely silent, more suitable for the functionality.

[2] In fact, the use of api is practically a necessity. Some other instrumentation has not yet implement the necessary method for hibernation/suspension, though provisions may have been made for.

[3] If you do not mind some utility, there are sure some shutdown.exe type utility out there with /standby switch, and then you can .run the utility's command line. Unfortunately, as far as I am aware of, native shutdown.exe may not have it (or with material os-dependent behaviour.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top