@ECHO OFFECHO ===================== Step 01 ==============================ECHO 1-1 查询需要修改的远程桌面端口号,默认为16进制显示REG QUERY "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WDS\RDPWD\TDS\TCP" /V "PORTNUMBER"REG QUERY "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WINSTATIONS\RDP-TCP" /V "PORTNUMBER"REM 1-2 修改上述两个端口REM 设置新的端口号到变量NEWPORTNUMBER中,以10进制表示SET NEWPORTNUMBER=34568REG ADD "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WDS\RDPWD\TDS\TCP" /V "PORTNUMBER" /T REG_DWORD /D %NEWPORTNUMBER% /FREG ADD "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WINSTATIONS\RDP-TCP" /V "PORTNUMBER" /T REG_DWORD /D %NEWPORTNUMBER% /FECHO 1-3 再次查询修改后的远程桌面端口号,看属否修改成功,默认为16进制显示REG QUERY "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WDS\RDPWD\TDS\TCP" /V "PORTNUMBER"REG QUERY "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WINSTATIONS\RDP-TCP" /V "PORTNUMBER"ECHO ===================== Step 02 ==============================ECHO 重启远程桌面有关的服务ECHO 先停止NET STOP "REMOTE DESKTOP SERVICES" /YECHO 再重启NET START "REMOTE DESKTOP SERVICES"ECHO ===================== Step 03 ==============================ECHO 打开远程桌面功能REG ADD "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER" /V "fDENYTSCONNECTIONS" /T REG_DWORD /D 00000000 /FECHO 查询修改后的状态REG QUERY "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER" /V "fDENYTSCONNECTIONS"
Step 01 ==============================
ECHO 1-1 查询需要修改的远程桌面端口号,默认为16进制显示
REG QUERY "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WDS\RDPWD\TDS\TCP" /V "PORTNUMBER"
REG QUERY "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WINSTATIONS\RDP-TCP" /V "PORTNUMBER"
REM 1-2 修改上述两个端口
REM 设置新的端口号到变量NEWPORTNUMBER中,以10进制表示
SET NEWPORTNUMBER=34568
REG ADD "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WDS\RDPWD\TDS\TCP" /V "PORTNUMBER" /T REG_DWORD /D %NEWPORTNUMBER% /F
REG ADD "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WINSTATIONS\RDP-TCP" /V "PORTNUMBER" /T REG_DWORD /D %NEWPORTNUMBER% /F
ECHO 1-3 再次查询修改后的远程桌面端口号,看属否修改成功,默认为16进制显示
REG QUERY "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WDS\RDPWD\TDS\TCP" /V "PORTNUMBER"
REG QUERY "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER\WINSTATIONS\RDP-TCP" /V "PORTNUMBER"
ECHO ===================== Step 02 ==============================
ECHO 重启远程桌面有关的服务
ECHO 先停止
NET STOP "REMOTE DESKTOP SERVICES" /Y
ECHO 再重启
NET START "REMOTE DESKTOP SERVICES"
ECHO ===================== Step 03 ==============================
ECHO 打开远程桌面功能
REG ADD "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER" /V "fDENYTSCONNECTIONS" /T REG_DWORD /D 00000000 /F
ECHO 查询修改后的状态
REG QUERY "HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\TERMINAL SERVER" /V "fDENYTSCONNECTIONS"