[代码] Windows系统远程端口修改bat代码

[复制链接]
本站网友  发表于 2021-3-30 21:57 |阅读模式

修改远程端口

如下代码之后将文本文档的后缀名更改为cmd或者bat格式的,保存,执行修改,重启服务器生效
  1. @echo off
  2. color 0a
  3. ::技术支持韩阳修改
  4. title  修改Windows 2003/2008远程桌面服务端口号
  5. echo *******************************************************************
  6. echo * 请输入您要更改的远程桌面端口号,范围:1024-65535,不能与其他端口冲突*
  7. echo *******************************************************************
  8. echo.
  9. set /p port=请输入端口:
  10. reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v PortNumber /t reg_dword /d %port% /f
  11. reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t reg_dword /d %port% /f
  12. netsh firewall set opmode mode = enable
  13. netsh firewall set portopening all 80 web enable
  14. netsh firewall set portopening all 3389 remote-pre enable
  15. netsh firewall set portopening all %port% remote enable
  16. echo.
  17. echo *******************************
  18. echo * 重新启动远程桌面*
  19. echo *******************************
  20. reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t reg_dword /d 1 /f
  21. reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t reg_dword /d 0 /f
  22. echo.
  23. echo 下面开始重新启动电脑以生效,请选择启动方式:
  24. echo 选择1手动重新启动
  25. echo 选择2自动重新启动
  26. set /p select=请您选择1,2:
  27. if  "%select%"=="1"  goto A
  28. if  "%select%"=="2"  goto B
  29. pause
  30. exit
  31. :A
  32. echo 退出,请手动重新启动电脑
  33. pause
  34. exit
  35. :B
  36. shutdown -r -t 1
  37. pause
  38. exit
复制代码

QQ|删帖注销|手机版|资源圈

GMT+8, 2024-5-4 05:26

Powered by Discuz!

© 20022-2026 Comsenz Inc.

快速回复 返回顶部 返回列表