Enable Terminal Services Active Desktop

Enables Terminal Services Active Desktop on a computer. To disable Active Desktop, set the value of the ActiveDesktop property to 0 instead of 1.

VBScript Code


Const ENABLED = 1
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    objItem.ActiveDesktop = ENABLED
    objItem.Put_
Next