SHUTDOWN

Action

Shuts down or reboots a computer.

 

Syntax

SHUTDOWN ("computer", "message", wait, force, options)

 

Parameters

Computer

The name of the computer that is to be shut down or rebooted. An empty string("") indicates the local computer.

Message

String that specifies a message to display in the Shutdown dialog box.

Wait

Optional parameter specifying the time in seconds that the dialog box is displayed. While the dialog box is displayed, system shutdown can be stopped by using the Win32 AbortSystemShutdown function.

If wait is not zero, SHUTDOWN displays a dialog box on the specified computer. The dialog box, which displays the name of the user who called the function and the message specified by message, prompts the user to log off. The system beeps when the dialog box is created.

The dialog box remains on top of other windows and can be moved but not closed. A timer counts down the time remaining before a forced shutdown. If the user logs off, the system shuts down immediately. Otherwise, the computer is shut down when the timer expires.

If wait is zero, the computer shuts down without displaying the dialog box, and the shutdown cannot be stopped by AbortSystemShutdown.

Force

Specifies whether applications with unsaved changes are forcibly closed. If force is not zero, applications are closed. If force is zero, a dialog box is displayed prompting the user to close the applications.

Options

Optional parameter specifying one of the following options.

Value

Action

1

Reboot computer after shutdown.

2

Poweroff the system after shutdown (NB: this option only works for the local system).

Returns

 

0

Computer shut down

System error code

Function failed

 

Remarks

SHUTDOWN does not work reliably on Windows 9x due to an issue in the underlying Windows API. As a workaround, the following command can be used:

SHELL "%windir%\RUNDLL32.EXE user.exe,ExitWindows"

 

Example

$RC = Shutdown("", "System is being rebooted to enable new settings.", 60, 0, 1)