In tip 2531 » Using SendKeys, I demonstrated a technique of including a registry change and keystrokes in a batch, by inplementing a Hibernate shortcut.
Wayne Dolby, a frequent visitor, pointed out that you can perform a Hibernate by using only the Sendkeys command.
When you press CTRL+ESC, followed by a u, the Shut Down Windows dialog is envoked. If Hibernate is one of the options, pressing an h will select it. Pressing Enter will them start hibernation. If you create Hibernate.vbs containing:
set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "^\{ESC\}uh\{ENTER\}"
you can place a shortcut to it on your desktop or Quick Launch Bar.
You can implement Logoff, Restart, Shutdown, and Standby by creating shortcuts to:
Windows 2000 |
Windows NT 4.0 |
|
Logoff.vbs |
set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "^\{ESC\}ul\{ENTER\}" |
set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "^\{ESC\}uc\{ENTER\}" |
Restart.vbs |
set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "^\{ESC\}ur\{ENTER\}" |
set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "^\{ESC\}ur\{ENTER\}" |
Shutdown.vbs |
set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "^\{ESC\}uls\{ENTER\}"
|
set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "^\{ESC\}us\{ENTER\}" |
Standby.vbs |
set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "^\{ESC\}ulss\{ENTER\}" |
|