Advertisement
TrashScrape

change the standard port on the Dedicated Server

Mar 28th, 2021
1,018
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.50 KB | None | 0 0
  1. off
  2. echo -------------------------------------------------
  3. echo - %~nx0
  4. echo -
  5. echo - Allows you to change the RDP port
  6. echo - (Note: RDP default is 3389 0xd3d in hex)
  7. echo -
  8. echo - Here is the current setting (in hex):
  9. reg query "hklm\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "PortNumber"
  10. echo -------------------------------------------------
  11. :: check admin
  12. net session >nul 2>&1
  13. if %errorLevel% == 0 (echo [Admin confirmed]) else (echo ERR: Admin denied. Right-click and run as administrator. & pause & goto :EOF)
  14. :: check admin
  15. set /p rdp_port="Change to port to (Press enter for default 3389):"
  16. if "%rdp_port%" EQU "" set rdp_port=3389
  17. echo - Continuing will set it to to %rdp_port%
  18. pause
  19. reg add "hklm\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "PortNumber" /t REG_DWORD /d %rdp_port% /f
  20. echo - Here is the new setting (in hex):
  21. reg query "hklm\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "PortNumber"
  22. echo ---------- Next we will add the port to firewall, then disconnect any running terminal services
  23. echo ---------- You should be able to reconnect using the new port (if you get disconnected)
  24. pause
  25. echo -- Adding to firewall rules ...
  26. netsh advfirewall firewall add rule name="RDP Port %rdp_port%" profile=any protocol=TCP action=allow dir=in localport=%rdp_port%
  27. echo -- Stopping and starting services ...
  28. net stop termservice /yes
  29. net start termservice
  30. :DONE
  31. echo ---------- Done
  32. shutdown /r
  33. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement