Windows – Stop Windows Remote Desktop via .bat file

remote desktopwindows

Is there a possibility to disable the Windows XP SP2 Remote Desktop feature with a .bat file? I already tried to find a service and just stop and start it but I had no luck.

The background is that I have to run time critical tests on a remote pc, and I have to make sure that nobody is logging in while a test is running. The PC needs a network connection so I need something Remote Desktop specific.

Best Answer

Disable Remote Desktop:

reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v "fDenyTSConnections" /t REG_DWORD /d "1" /f

Enable Remote Desktop:

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

It's worth noting that if you're using Group Policy to enable Remote Desktop, you should just use Group Policy to disable it. Else, you will need to tickle this key/value instead :

HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\fDenyTSConnections