Vbscript / Operating System / Remotely Enable Remote Desktop
Enable remote desktop on a remote computer without directly editing the registry.
strComputer = InputBox ("Target Computer", "Enable Remote Desktop", default, 100, 100) strUser = InputBox ("Username (DOMAIN\Administrator)", "Enable Remote Desktop", default, 100, 100) strPass = InputBox ("Password", "Enable Remote Desktop", default, 100, 100)
strNameSpace = "root\cimv2" strClass = "Win32_TerminalServiceSetting"
Const ENABLE_CONNECTIONS = 1 Const DISABLE_CONNECTIONS = 0
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") Set objSWbemServices = objSWbemLocator.ConnectServer (strComputer, strNameSpace, strUser, strPass)
Set colClass = objSWbemServices.ExecQuery("Select * from " & strClass) For Each objItem in colClass intErr = objItem.SetAllowTSConnections(ENABLE_CONNECTIONS) Next
If intErr = 0 THEN Wscript.echo "Remote Desktop is now enabled on " & strComputer Else Wscript.echo "There was a problem enabling Remote desktop on " & strComputer End If
Please note that a disclaimer applies to any code on this page.
|