I don't think anyone here has given the right answer yet.
It is possible to do this, I believe, but I think you must apply group
policy.
I think it you need to turn the feature on and reboot--I don't think you can
start the necessary services without a reboot.
I think the info at this link:
http://www.microsoft.com/technet/pr...elp/1e4a44de-2be1-4d29-9387-9f04b79cc17a.mspx
is probably accurate for Windows XP. I'm not sure whether this setting is
available without the Windows Server 2003 templates being available however.
Here's a real blast from the past--from Alex Angelopoulos in September 2002,
as published in RemoteNetworking (digest version) by Jeffery Randow:
--------------------------------
What you are after is under the following key in the local registry:
"HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\"
The value of interest is a DWORD named:
"fDenyTSConnections"
Setting this flag to FALSE (0) should handle it for you.
Here's the problem: I cannot confirm that doing this programmatically
enables/disables RD. It MAY need a reboot to take effect after the
state change. Doing the registry edit in the GUI makes the chnage
instantly; doing it from script makes the change in the registry, but
the service does not start listening right away, so a "change and run"
script would require remotely reinitializing this somehow - probably
telling the service to re-read its settings, which I haven't looked into
yet.
Here's a VBScript function that does the state change, then returns a
result of "true if it succeeds and "false" if it doesn't. The reboot
test needs to be done...
Function SetRdState(desiredState)
' Set to true to enable RD on XP Pro
' False to disable
' returns true if call succeeds, false on error
Dim Sh, key_TS, keyValue
SetRdState = False
Set Sh = CreateObject("WScript.Shell")
Key_TS = "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\"
keyValue = Clng(Abs(CInt(desiredState)))
WScript.Echo "Desired value is", keyValue
On Error Resume Next
Err.Clear
Sh.RegWrite Key_TS & "fDenyTSConnections", keyValue, "REG_DWORD"
If Err.Number = 0 Then SetRdState = True
Err.Clear
On Error Goto 0
End Function