Remotely Enabling Remote Desktop .VBS script

What if you’ve deployed a Windows Server 2003 box in a remote location but forgot to enable Remote Desktop on it so you can administer it remotely?

This script should help in remotely enabling Remote Desktop Connection.

‘========================================================
‘Script name: EnableRemoteDesktop.vbs
‘Author: Ronni Pedersen
‘Last modified: 14/01-2005
‘Version: 1.04
‘========================================================
‘========================================================

strComputer = InputBox (“Target Computer”,
“Enable Remote Desktop”, default, 100, 100)
strBruger = 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,
strBruger, strPass)

Set colClass = objSWbemServices.ExecQuery(“Select * from ” & strClass)
For Each objTing in colClass
errAngivelse = objTing.SetAllowTSConnections(ENABLE_CONNECTIONS)
Next

If errAngivelse = 0 THEN
Wscript.echo “Remote Desktop is now enabled on ” + strComputer
Else
Wscript.echo “Houston, we have a problem…!!!”
End If

‘========================================================
‘ End of Script
‘========================================================

Source: windowsdevcenter.com

Advertisements

One thought on “Remotely Enabling Remote Desktop .VBS script

  1. It is in reality a nice and helpful piece of info. I’m happy that you just shared this useful info with us. Please keep us informed like this. Thank you for sharing.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s