The simple script below will enable Remote Desktop using WMI. It takes effect in a few seconds.
Supply a username and password if you don't have administrative rights natively. Yes, this exposes the password.
strComputer = "."
strUsername = ""
strPassword = ""
If WScript.Arguments.Count > 0 Then
strComputer = WScript.Arguments(0)
If Left(strComputer, 2) = "\\" Then
strComputer = Mid(strComputer, 3)
End If
WScript.Echo "Querying \\" & strComputer & "..." & vbCrLf
End If
If WScript.Arguments.Count > 1 Then
strUserName = WScript.Arguments(1)
End If
If WScript.Arguments.Count > 2 Then
strPassword = WScript.Arguments(2)
End If
Set objLocator = CreateObject("WBEMScripting.SWBEMLocator")
Set objWMIService = objLocator.ConnectServer(strComputer, "root/cimv2", _
strUsername, strPassword)
Set colItems = objWMIService.ExecQuery("Select * from Win32_TerminalServiceSetting")
For Each objItem In colItems
WScript.Echo "AllowTSConnections: " & objItem.AllowTSConnections
If objItem.AllowTSConnections = 0 Then
WScript.Echo "Enabling Terminal Services connections..."
objItem.SetAllowTSConnections(1)
Else
WScript.Echo "Already enabled."
End If
Next