Sharing Knowledge | System Admin Articles

Enable Remote Desktop Through a Script



To use copy the code below and paste into a file with a text file with a .vbs extension. This will work for the local machine. Just replace the perion part that is mentioned in this string to another computer name if you

want have it work on one machine - strComputer - "."


Const ENABLE_CONNECTIONS = 1 strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_TerminalServiceSetting") For Each objItem in colItems errResult = objItem.SetAllowTSConnections(ENABLE_CONNECTIONS) Next
By the way if you want to turn off Remote Desktop just change the 1 in this line of code

Const ENABLE_CONNECTIONS = 1 to a 0 (Zero).


Labels: Windows

About the Author
My Profile Photo

I'm Shankar, A Windows System Admin. I'm Experienced in Windows Server Technologies and Citrix Administration. I'm blogging since 2009 and I'm currently working for a Organization as Senior System Engineer.
Follow Me On Twitter or On Facebook

0 Comments for "Enable Remote Desktop Through a Script"

What do you think about this Article? Add your Opinion..!

Back To Top