/build/static/layout/Breadcrumb_cap_w.png

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.


0 Comments   [ + ] Show comments

Answers (4)

Posted by: SMal.tmcc 11 years ago
Red Belt
2

your call should be something like:

reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\Control\Terminal Server" /v fDenyTSConnections /d 0 /T REG_DWORD /f

http://social.technet.microsoft.com/wiki/contents/articles/4980.how-to-enable-or-disable-remote-desktop-via-group-policy-windows-2008.aspx

Posted by: KevinViolette 11 years ago
5th Degree Black Belt
1

you can enable remote desktop with Group Policy with minimal effort.

check out this blog post if that interests you. 

http://www.twistedethics.com/2009/01/06/how-to-enable-remote-desktop-via-group-policy/

 

Posted by: jdornan 11 years ago
Red Belt
0

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
Posted by: M P 11 years ago
Purple Belt
0

If you actually saw the registry key get imported successfully on the test box, you may have to restart your computer for the actual check box to appear as checked in the System properties.  Let me know if that works.

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ