Windows Script 修改RD...
 
Notifications
Clear all

Windows Script 修改RDP3389远程访问端口,修改用户密码和重启计算机  

  RSS

tai chi
(@taichi)
Estimable Member
Joined: 2 months ago
Posts: 220
23/05/2020 1:04 pm  

@echo off
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
title www.nat.ee
mode con: cols=36 lines=10
color 17
set "ing=ping -n 5 127.0.0.1 > nul"
set "rdp=HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules"
:Menu
cls
echo ==============================
echo.
echo 1.修改远程端口
echo.
echo 2.修改用户密码
echo.
echo 3.重启计算机
echo.
echo ==============================
choice /C:123 /N /M "请输入你的选择 [1,2,3]":
if errorlevel 3 goto:Restart
if errorlevel 2 goto:Password
if errorlevel 1 goto:RemotePort
:RemotePort
cls
echo 修改远程桌面端口
echo 按回车键(Enter)确定
set /P "Port=自定义范围(1-65535):"
if %Port% leq 65535 (
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v "PortNumber" /t REG_DWORD /d "%Port%" /f > nul
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "PortNumber" /t REG_DWORD /d "%Port%" /f > nul
Reg add "%rdp%" /v "RemoteDesktop-UserMode-In-UDP" /t REG_SZ /d "v2.10|Action=Allow|Active=TRUE|Dir=In|Protocol=17|LPort=%Port%|App=%%SystemRoot%%\system32\svchost.exe|Svc=termservice|[email protected],-101|[email protected],-102|[email protected],-28852|" /f > nul
Reg add "%rdp%" /v "RemoteDesktop-In-TCP" /t REG_SZ /d "v2.10|Action=Allow|Active=TRUE|Dir=In|Protocol=6|LPort=%Port%|App=System|[email protected],-28753|[email protected],-28756|[email protected],-28752|" /f > nul
Reg add "%rdp%" /v "RemoteDesktop-UserMode-In-TCP" /t REG_SZ /d "v2.10|Action=Allow|Active=TRUE|Dir=In|Protocol=6|LPort=%Port%|App=%%SystemRoot%%\system32\svchost.exe|Svc=termservice|[email protected],-28853|[email protected],-28856|[email protected],-28852|" /f > nul
cls
echo 修改成功
echo 请牢记,你的远程端口是: %Port%
echo 重启计算机生效
%ing% && goto:Menu) else (echo 错误的端口,%Port% 大于所设置的范围,请在"1-65535"内。
%ing% && goto:RemotePort)
:Password
cls
echo 当前修改用户: %username% 密码
echo 按回车键(Enter)确定
set /p pwd1=请输入密码:
cls
echo 按回车键(Enter)确定
set /p pwd2=请再次输入密码:
if "%pwd1%"=="%pwd2%" (
net user %username% %pwd2% > nul
cls
echo 修改成功,请牢记你的密码。
%ing% && goto:Menu)else (cls
echo 密码错误,请重新输入。
%ing% && goto:Password)
:Restart
shutdown.exe /r /f /t 0


Quote
Topic Tags
Share:
%d bloggers like this: