一键修改windows server2008默认远程访问的端口号

远程访问默认端口号是3389,感觉有必要改一下,免得被那些小菜鸟用工具扫过来扫过去的!

百度搜了一下资料,经过测试,以下代码可用。

省去的又要修改注册表,还得设置防火墙入站规则麻烦,特别记录一下。

@echo off  
color f0  
echo 修改远程桌面3389端口(支持Windows 2003 2008 2008R2 2012 2012R2 7 8 10 )  
echo 自动添加防火墙规则  
echo %date%   %time%  
echo    ARK  
set /p c= 请输入新的端口:  
if "%c%"=="" goto end  
goto edit  
:edit  
netsh advfirewall firewall add rule name="Remote PortNumber" dir=in action=allow protocol=TCP localport="%c%"  
netsh advfirewall firewall add rule name="Remote PortNumber" dir=in action=allow protocol=TCP localport="%c%"  
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v "PortNumber" /t REG_DWORD /d "%c%" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "PortNumber" /t REG_DWORD /d "%c%" /f
echo 修改成功  
echo 按任意键退出
echo "%c%"
pause  
exit  
:end  
echo 修改失败  
pause 

1、将代码复制到txt记事本中,再将后缀名改成 .bat

2、执行,再重新启动就会生效。(网上搜来的的代码是自动重启的,感觉不太妥当,就去掉了。 服务器的重启还是谨慎点好!)

posted @ 2018-05-10 15:04  快乐星  阅读(292)  评论(0)    收藏  举报