@echo off
color 1f
title 关闭常见的危险端口
echo 正在开启Windows防火墙
echo.
netsh advfirewall set currentprofile state on > nul
netsh advfirewall set publicprofile state on > nul
echo.
echo 防火墙已经成功启动。
echo.
echo 正在开启60051远程端口…
netsh advfirewall firewall add rule name="60051" protocol=TCP dir=in localport=60051 action=allow
echo 正在修改注册表远程端口为60051…
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v PortNumber /t REG_DWORD /d 60051 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d 60051 /f
echo 正在关闭Remote Desktop Services…
net stop "Remote Desktop Services" /y
echo 正在启动Remote Desktop Services…
net start "Remote Desktop Services"
echo.
echo.