Platforms to show: All Mac Windows Linux Cross-Platform

ExitWindowsMBS(mode as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method System MBS Win Plugin ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Shutdown a Windows PC.
Example
dim b as boolean
b=ExitWindowsMBS(0)

Mode constants:
LOGOFF0Shuts down all processes running in the security context of the process that called the ExitWindows function. Then it logs the user off.
SHUTDOWN1Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped.
REBOOT2Shuts down the system and then restarts the system.
FORCE4Forces processes to terminate. When this flag is set, the system does not send the WM_QUERYENDSESSION and WM_ENDSESSION messages. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.
POWEROFF8Shuts down the system and turns off the power. The system must support the power-off feature.
FORCEIFHUNG16(Windows 2000) Forces processes to terminate if they do not respond to the WM_QUERYENDSESSION or WM_ENDSESSION message. This flag is ignored if FORCE is used.

Returns true if successfull.

The ExitWindows function returns as soon as it has initiated the shutdown. The shutdown or logoff then proceeds asynchronously.

During a shutdown or log-off operation, applications that are shut down are allowed a specific amount of time to respond to the shutdown request. If the time expires, the system displays a dialog box that allows the user to forcibly shut down the application, to retry the shutdown, or to cancel the shutdown request. If the FORCE value is specified, the system always forces applications to close and does not display the dialog box. If the FORCEIFHUNG value is specified, the system forces hung applications to close and does not display the dialog box.

Windows NT: To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege.

Some FAQ entries about this method:

Blog Entries

The items on this page are in the following plugins: MBS Win Plugin.


The biggest plugin in space...