The ControlConnection method enables or disables incoming Terminal Services connections for the specified server. In addition, when connections are disabled, this method also immediately terminates all existing sessions. This may result in loss of data in those sessions.

This setting would be manually controlled by right-clicking on the connection in the Terminal Services Connection Configuration snap-in and selecting All actions/Enable connection or Disable connection.

In order for this method to successfully execute, either

 Sample Code
 Applies To
 See Also