9.9.1 ExitWindows (terminate a script and log off or shut down Windows)
- Purpose
-
Terminates script execution and logs off from Windows, or turns off or reboots the Windows system.
- Syntax
ExitWindows([Code] [, Option1, Option2])
- Arguments
-
- Code
-
Specify the exit code as a number or as a variable that stores this value.
If you omit this argument, zero is assumed.
- Option1
-
Specify the shutdown type as one of the following values:
Value
Meaning
Logoff
Shut down all active processes, then log off the current user.
Poweroff, Shutdown
Shut down and power off the system.
The right to shut down the system is required. The system must support software-driven poweroff.
Depending on the Do not turn off system power after a Windows system shutdown has occurred. setting in the Windows group policy settings, the user can power off the system after it is shut down.
Reboot
Restart the system after shutdown. The right to shut down the system is required.
Force
Forcibly terminate the process without displaying an application did not respond message if an application fails to respond to a shutdown.
This value is optional. If you omit this value, Logoff is assumed.
- Option2
-
If you specified a value other than Force in Option1, specify the following optional value as the shutdown operation to be used in conjunction with Option1:
Value
Meaning
Force
Forcibly terminate the process without displaying an application did not respond message if an application fails to respond to a shutdown.
- Description
-
The ExitWindows command terminates script execution and exits Windows using the specified type of shutdown operation.
For details on JP1/Script exit codes, see 6.1.12 JP1/Script exit codes.
- Note
-
At execution of this command, a message is output to the application log at the Event Viewer. The event ID is 5.
Output to the event log is suppressed when the parameter /NOEVLOG or /NOEVLOG(5) is set in the command line defined in the execution environment file or in the command line set in the registry.
- Important
-
-
If you execute the ExitWindows command while another program or service is running, that program or service may malfunction. Exercise care when you use the ExitWindows command.
-
If you execute multiple ExitWindows commands at the same time, the operation specified for Option1 might be disabled or the OS might stop.
-
If you execute the ExitWindows command by using a script file started from JP1/AJS3, the JP1/AJS3 environment might be damaged.
-
The ExitWindows command does not function in the following cases:
- The command is executed from a service for which an account without permission to shut down the system has been set.
- The command is executed from the logon space of a computer to which the user logged on with an account without permission to shut down the system.
- Force is not specified in the command's Option1 or Option2 and the running application rejects the shutdown request. However, if the command is executed from a service, the command takes effect regardless of whether Force is specified (except Logoff).
- Force is not specified in the command's Option1 or Option2 and the computer to which the user logged on is locked. However, if the command is executed from a service, the command takes effect regardless of whether Force is specified (except Logoff).
- Logoff is specified in Option1 and the command is executed from a service.
-
- Example
MessageBox("Do you want to terminate the script and shut down the system?", OKCancel) If _MSG_RTN_ = OK Then ExitWindows(0, Shutdown) Else Exit(0) End
- JP1/Script version
-
Supported from JP1/Script 05-10.