Friday, April 10, 2009

Enable Remote Desktop on a Remote Desktop...uhhhh... Remotely

Here's a little BAT script to turn on Remote Desktop availability on a remote computer. For those situations when you forgot to enable it manually, forgot to use Group Policy to enable it, and already drove/flew/rode/walked back to another location (far away of course) and just realized you forgot to take care of that. Not me. I've never done anything like that. :)

@echo off
if [%1]==[] goto ERRFAIL else goto POKE

:POKE
echo Checking to see if %1 is online...
if exist \\%1\ADMIN$\SYSTEM32\mstsc.exe goto CONFIG else goto ERRPOKE

:CONFIG
reg add "\\%1\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0
shutdown /m \\%1 /r /f /t 0 /c "remote shutdown requested"
goto END

:ERRPOKE
echo Error: Computer is not accessible
echo .
goto END

:ERRFAIL
echo Error: No computer name was provided
echo .
echo Usage: rdpset.bat COMPUTERNAME
echo .
goto END

:END
Post a Comment