I'm looking for a way to disable Remote Desktop login for Windows 2008 for a specific user (a local administrator account), either using the command line or a script (such as VBS) in Windows 2008.
I understand I need to modify the local security policy, however, I have not found a way to perform this via either cmd or a script-based solution.
Anyone have any recommendations to how to solve this?
Best Regards
Anders L.
To disable remote desktop from windows command line run the below command as administrator:
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f
To enable remote desktop from windows command line run the following command as administrator:
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
Create a registry file (.reg) with this in it:
Then use
regedit /s yourregfile.reg
If you want to script it better than that, use vbscript:
enable or disable rdp (remote desktop) on remote system.vbs
If you want to learn more on managing local group policies, check this Microsoft KB, it seems to cover a lot: Step-by-Step Guide to Managing Multiple Local Group Policy Objects
Save as a bat file, the open an CMD "rdpdisabler.bat PCNAME
In the end I ended up using a solution built upon VBS (the horror) and
secedit
.