Sunday, January 29, 2006

Enabling RDP

Rdp is one of those settings that is a simple click. However, it comes back to a simple click on 30 computers adds time. Therefore since I use rdp on almost all of my XP pro clients, I choose to come up with a way to add this functionality with a script. I scoured the internet and several books and found no tutorials on doing this. This does not mean they aren't there, simply that I did not find them. I choose a different route this time. First I downloaded windiff. This program will allow me to specify two different versions of a file and it will give me the precise changes over the versions. I turned off RDP on my home computer and exported the registry. I then turned rdp back on and reexported the registry. Upon running windiff on these to files I was shocked to find only two keys changed. This is either a stroke of good luck or a problem caused by the fact that this was not the first time I had enabled RDP. The below keys were all that had changed: [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Terminal Server] "fDenyTSConnections"=dword:00000001 ''Remote Desktop Disabled "fDenyTSConnections"=dword:00000000 ''Remote desktop Enabled [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server] "fDenyTSConnections"=dword:00000001 ''Remote Desktop Disabled "fDenyTSConnections"=dword:00000000 ''Remote Desktop Enabled As a test I created two .reg files to apply the changes. It appears to have worked flawlessly. So it is now time to convert this into a script. After wasting a half an hour because of a typo I was able to produce a short and sweet script to enable RDP.
Function GetCompName()
Dim objNetComp
Dim strComputer
''Get current name of comp
Set objNetComp = CreateObject("WScript.NetWork")
strComputer = cstr(objNetComp.ComputerName)
GetCompName = strComputer
End Function

Function EditRegistry(strCompName)
Dim key Dim strKeyPath
Dim objReg
Dim intRc
Dim regVal
regVal = 0
''Setup registry for edit
Const HKLM = &H80000002
strKeyPath = "SYSTEM\ControlSet001\Control\Terminal Server"
''Edit the Registry
''set 1
Set objReg = GetObject("winmgmts:\\" & strCompName & \root\default:StdRegProv")
intRc = objReg.SetDWORDValue(HKLM, strKeyPath, "fDenyTSConnections", regVal)
''set 2
strKeyPath = "SYSTEM\CurrentControlSet\Control\Terminal Server"
intRc = objReg.SetDWORDValue(HKLM, strKeyPath, "fDenyTSConnections", regVal)
End Function
Dim compName
compName = GetCompNameEditRegistry(compName)

0 Comments:

Post a Comment

<< Home