Turn off the computer by running a script.

G

Guest

I am looking for a way to shut down the computer (running Windows XP Home) by
script or command. It is important that the script or command completely
turn off the computer since it's a laptop and has no separate switch for the
screen.

The following command will shut down the hard drive, but it doesn't work
well on a laptop because the screen doesn't turn off until the power button
is pressed.
%windir%\System32\shutdown.exe -s -t 00

This calls up the box, but doesn't go any further.
Set objShell = CreateObject("Shell.Application")
objShell.ShutdownWindows

A "SendKeys" statement can be used to elect the "Turn Off" option. This
usually works, but the "SendKeys" command is rather unreliable in this usage
and sometimes fails.
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objShell = CreateObject("Shell.Application")
objShell.ShutdownWindows
WScript.Sleep 200
WshShell.SendKeys "U"

Is there another paramater to elect the "Turn Off" option for the command...
objShell.ShutdownWindows

....or, is there a DLL for shutting down like this one used to hibernate?
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("%windir%\System32\rundll32.exe Powrprof.dll,SetSuspendState")

Any help would be appreciated.
Thanks,
DJ1
 
J

jwill

DJ1 said:
I am looking for a way to shut down the computer (running Windows XP Home) by
script or command. It is important that the script or command completely
turn off the computer since it's a laptop and has no separate switch for the
screen.

The following command will shut down the hard drive, but it doesn't work
well on a laptop because the screen doesn't turn off until the power button
is pressed.
%windir%\System32\shutdown.exe -s -t 00

This calls up the box, but doesn't go any further.
Set objShell = CreateObject("Shell.Application")
objShell.ShutdownWindows

A "SendKeys" statement can be used to elect the "Turn Off" option. This
usually works, but the "SendKeys" command is rather unreliable in this usage
and sometimes fails.
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objShell = CreateObject("Shell.Application")
objShell.ShutdownWindows
WScript.Sleep 200
WshShell.SendKeys "U"

Is there another paramater to elect the "Turn Off" option for the command...
objShell.ShutdownWindows

...or, is there a DLL for shutting down like this one used to hibernate?
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("%windir%\System32\rundll32.exe Powrprof.dll,SetSuspendState")

Any help would be appreciated.
Thanks,
DJ1

http://aumha.org/win5/a/shutcut.php
 
J

Joe K

DJ1 said:
I am looking for a way to shut down the computer (running Windows XP Home) by
script or command. It is important that the script or command completely
turn off the computer since it's a laptop and has no separate switch for the
screen.

The following command will shut down the hard drive, but it doesn't work
well on a laptop because the screen doesn't turn off until the power button
is pressed.
%windir%\System32\shutdown.exe -s -t 00

This calls up the box, but doesn't go any further.
Set objShell = CreateObject("Shell.Application")
objShell.ShutdownWindows

A "SendKeys" statement can be used to elect the "Turn Off" option. This
usually works, but the "SendKeys" command is rather unreliable in this usage
and sometimes fails.
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objShell = CreateObject("Shell.Application")
objShell.ShutdownWindows
WScript.Sleep 200
WshShell.SendKeys "U"

Is there another paramater to elect the "Turn Off" option for the command...
objShell.ShutdownWindows

....or, is there a DLL for shutting down like this one used to hibernate?
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("%windir%\System32\rundll32.exe Powrprof.dll,SetSuspendState")

Any help would be appreciated.
Thanks,
DJ1
Go to http://www.grc.com/wizmo/wizmo.htm and read about Wizmo.It's a
great shortcut I use to reboot. It has many options.Shutdown is one of them.
 
T

Torgeir Bakken \(MVP\)

DJ1 said:
I am looking for a way to shut down the computer (running Windows XP Home) by
script or command. It is important that the script or command completely
turn off the computer since it's a laptop and has no separate switch for the
screen.

The following command will shut down the hard drive, but it doesn't work
well on a laptop because the screen doesn't turn off until the power button
is pressed.
%windir%\System32\shutdown.exe -s -t 00

(snip)
Hi,

Try the vbscript in this post and see if it works better:
http://groups.google.co.uk/group/mi...g.wsh/msg/70e52cfd8781bd56?dmode=source&hl=en
 

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