Submitted By: Andre Zouain

Enables remote desktop connections on the target computer.

Visual Basic
Edit|Remove
'This script enables remote desktop connections on the target host
'very useful for support when you don't have RDM
'Scripted by Andre Zouain

Const ENABLE = 1
Const ENABLE_CONNECTIONS = 1
 
strComputer = InputBox("Hostname")
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_Terminal Where TerminalName = 'Accounting'")

For Each objItem in colItems
    errResult = objItem.Enable(ENABLE)
Next

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

For Each objItem in colItems
    errResult = objItem.SetSingleSession(ENABLE)
    errResult = objItem.SetAllowTSConnections(ENABLE_CONNECTIONS)
Next