Enable Remote Desktop
I have been working on a script that will enable remote desktop across our organization. I have found the registry key necessary in windowsxp and wrote a script that modifies the following key and then reboots the machine.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
I have the script change fDenyTSConnections to a value of 0 (which is supposed to enable remote desktop). I did this by exporting the entire HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server key after enabling remote, and then writing a batch file that imports this key (from a network location).
I look on my test box after the import, and it appears it indeed imported the correct key into the registry, but I right click on "my computer" and choose "properties" and then look in the remote tab...and remote desktop is still turned off.
Does anyone have a script, or know of a way to successfully enable remote desktop on a machine remotely through a kbox script (or a batch file that I can incorporate into a kbox script)?
Any insight, as always, is appreciated.
Answers (4)
Eh a little out of the box but this script will enable or disable RDP remotely. I use it often, sure it could be modded to your needs pretty easily.
const HKEY_LOCAL_MACHINE = &H80000002 strComputer = InputBox("Enter the COMPUTER NAME of the system you want to enable or disable Remote Desktop","Enable or Disable Remote Desktop","Localhost") If strComputer = "" Then WScript.Quit End If Set StdOut = WScript.StdOut On Error Resume Next Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") If Err.Number <> 0 Then WScript.Echo "An error has occurred. You may have mistyped the computer name." WScript.Quit End If strKeyPath = "SYSTEM\CurrentControlSet\Control\Terminal Server" strValueName = "fDenyTSConnections" oReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue If dwValue = 1 Then prompt = MsgBox ("Remote Desktop is Currently disabled. Do you want to ENABLE it?", vbYesNo) If prompt = vbYes then dwValue = 0 oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue WScript.Echo "Remote Desktop is now ENABLED on " & strComputer WScript.Quit ElseIf prompt = vbNo then WScript.Echo "Remote Desktop is still DISABLED." Wscript.Quit End If ElseIf dwValue = 0 then prompt = MsgBox ("Remote Desktop is Currently ENABLED. Do you want to DISABLE it?", vbYesNo) If prompt = vbYes then dwValue = 1 oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue WScript.Echo "Remote Desktop is now DISABLED on " & strComputer WScript.Quit ElseIf prompt = vbNo then WScript.Echo "Remote Desktop is still ENABLED." WScript.Quit End If End If