wtsShutdownSystem

Shuts down a terminal server system.

Syntax:

wtsShutdownSystem(server,flag)

Parameters:

(s) server: This is the name of the terminal server system which will be shut down. The server name should have the leading "\\" characters on it. Passing in an empty string for this parameter will cause the local terminal server system to be used.

(i) flag:This is an integer value that specifies what type of shutdown is to be performed. Refer to the "Notes:" section for more information about the flag values that are defined for this parameter.

Returns:

(i) Returns @TRUE on sucess or @FALSE on failure.

 

This function allows for a terminal server system to be shut down remotely. Various types of shut down activities can be performed, such as logging off all users except for the system console session, rebooting the server, shutting down the server, shutting down the server and then having it power itself off, etc...

The following values are defined for the "flag" parameter. Any one of these values may be passed in, but do not combine them as they are not a bit-mask value and combining multiple flag values will have unpredictable results.

Value

Meaning

 

 

Logoff all user sessions except for the one that called this function. Also, the system console session will never be logged off by this flag value. The terminal server system has logons disabled and they won't be re-enabled until the server is rebooted. This flag value is good for clearing off all users from a server before actually shutting it down.

Shutdown the terminal server. All sessions, including the system console session, will be logged off. The server will shutdown and remain in that state.

4

Reboot the server, with all sessions being logged off before the reboot actually occurrs. The system console session will be logged off.

8
 

Power down the server. All sessions, including the system console session, will be logged off. Then, the server will shut itself down and then it will use power management [if available] to power itself off.

16

 

Fast reboot. The MSDN Platform SDK indicates that although this flag value is defined, it is not currently supported. If this flag value does end up becoming supported, then it is supposed to perform a reboot of the terminal server system w/o first logging off all sessions.

 
Example:
;Load 32-bit or 64-bit extender
AddExtender( "WWWTS44I.DLL" , 0, "WWWTS64I.DLL" )

Title01 = 'Test wtsShutdownSystem()' ServerSpec = AskLine('Shutdown a terminal server system','Server','') Flag = AskLine('Shutdown a terminal server system','Shutdown flag value','') ErrorMode(@OFF) Result = wtsShutdownSystem(ServerSpec,Flag) RC = LastError() ErrorMode(@CANCEL) TempMsg = StrCat('wtsShutdownSystem("',ServerSpec,'",',Flag,') RC = ',RC,@CRLF) TempMsg = StrCat(TempMsg,@CRLF,@CRLF,'Result = ',Result) Message(Title01,TempMsg) Exit
See Also:

wtsDisconnectSession, wtsLogoffSession, wtsTerminateProcess