修改3389为53389
cls
@color 0A
@mode con cols=80 lines=32
@title ★修改默认3389端口★
@echo off
echo =====================================================
echo ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
echo ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
echo ※ 修改3389.bat v1.0 ※
echo ※ create by jim ※
echo ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
echo ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
echo 时间:%date% %time%
echo =======================================================
echo 用途:通过修改注册表,修改默认3389端口
echo =======================================================
goto :3389-1
:3389-1
::***********************************************************
::导出3389端口默认注册表
reg export "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" c:\3389.reg
goto :3389-2
:3389-2
set port1=53389
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /t REG_DWORD /v portnumber /d %port1% /f
set port2=53389
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\wds\rdpwd\tds\tcp" /t REG_DWORD /v portnumber /d %port1% /f
if %port1%==%port2% (echo 修改成功!!!) else (echo 两次输入不一致,请重新输入。&goto 3389-2)
goto :QUIT
:QUIT
netsh firewall set portopening tcp 53389 mstsc-53389 enable
net stop TermService
net start TermService
echo ________________________________________________________
echo.
echo ________________________________________________________
echo [Press any key to quit]
echo ________________________________________________________
echo.
pause >nul
exit