查询
REG查询3389状态
0-开 1-关
REG query "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections
REG查询3389端口
REG query "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds" /s
REG query "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber
set /a Port=0xd3d
tasklist、netstat命令查询3389端口
tasklist /svc | findstr "TermService"
netstat -ano | findstr "2028"
开启3389端口
REG命令行开启3389端口
XP/Win2k3/Win7/Win2k8/Win8.1/Win10/2012/2016(0:开、1:关)
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
2003开启3389端口
wmic path win32_terminalservicesetting where (__CLASS !="") call setallowtsconnections 1
08/12开3389
在 Windows Server 2008 和 Windows Server 2012 中开启 3389 端口
wmic /namespace:\root\cimv2\terminalservices path win32_terminalservicesetting where (__CLASS !="") call setallowtsconnections 1
wmic /namespace:\root\cimv2\terminalservices path win32_tsgeneralsetting where (TerminalName='RDP-Tcp') call setuserauthenticationrequired 1
reg add "HKLM\SYSTEM\CURRENT\CONTROLSET\CONTROL\TERMINAL SERVER" /v fSingleSessionPerUser /t REG_DWORD /d 0 /f
win7 开启3389
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 00000000 /f
REG文件开启远程桌面
Windows Registry Editor Version 5.00HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server]"fDenyTSConnections"=dword:00000000[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp]"PortNumber"=dword:00000d3d ////
保存micropoor.reg,并执行regedit /s micropoor.reg
注:如果第一次开启远程桌面,部分需要配置防火墙规则允许远程端口。netsh advfirewall firewall add rule name="Remote Desktop" protocol=TCP dir=in localport=3389 action=allow
WMIC命令开启3389端口
Win2k3/Win7/Win2k8/Win8.1/Win10/2012/2016(0:开、1:关)
wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call SetAllowTSConnections 1
前提条件是确保“Windows Management Instrumentation(Winmgmt)”服务已正常启动。
WMIC开启远程主机3389端口
Win2k/XP/Win2k3
wmic /node:192.168.0.103 /user:administrator /password:betasec PATH win32_terminalservicesetting WHERE (__Class!="") CALL SetAllowTSConnections 1
Win7/Win2k8/Win8.1/Win10/2012/2016
wmic /node:192.168.0.116 /user:administrator /password:betasec RDTOGGLE WHERE ServerName='WIN-TO2CN3V2VPR' call SetAllowTSConnections 1wmic /node:192.168.0.116 /user:administrator /password:betasec process call create 'cmd.exe /c REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f'
调用Windows API接口开启3389
https://github.com/3had0w/Open3389