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

Comments

Please log in to comment

Answers

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

Answered 01/18/2013 by: SMal.tmcc
Red Belt

Please log in to comment
2

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/

 

Answered 01/18/2013 by: KevinViolette
Fourth Degree Black Belt

Please log in to comment
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
Answered 01/19/2013 by: jdornan
Red Belt

Please log in to comment
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.

Answered 03/25/2013 by: M P
Purple Belt

Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share