Can I do this with BAT files?


Conan Kelly

Hello all,

I have created icons on my desktop to Logoff, Restart, Shutdown, and Standby
(somebody on these NG's showed me where I could download another
Shutdown.exe that supports Standby since the default one that comes with
Windows does not) my computer.

I was trying to create a BAT file that would first log me off and then put
the computer into standby:
%windir%\System32\Shutdown.exe -l -t 0
"C:\Program Files\Shutdown\shutdown.exe" -s -t 0

The problem I am having is that it first executes the logoff command and
then immediatly tries to execute the standby command with the logoff still
in progress. Is there a way to execute the Logoff command from the batch
file in a way that it will complete before executing any other commands? If
I do it this way, will the batch file still be running after the logoff
completes? In otherwords, will the batch file still be running and be able
to execute the standby command even after I have logged off?

Thanks for any help anyone can provide,

Conan Kelly

Ramesh, MS-MVP

You may use PSExec or AT command-line to accomplish this.

"C:\Tools\psexec.exe" -i -s wscript.exe F:\MyScript.vbs

F:\MyScript.vbs contains:
- - -
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("%windir%\System32\Shutdown.exe -l -t 0")
WScript.Sleep 10000
Return = WshShell.Run("C:\Program Files\Shutdown\shutdown.exe -s -t 0")
- - -

Get PSExec from Sysinternals

Ramesh, Microsoft MVP
Windows XP Shell/User

Windows XP Troubleshooting

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