- 1:表示关闭
- 0:表示开启
EXEC master..xp_regread 'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\Terminal Server',
'fDenyTSConnections'
EXEC master..xp_regread 'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp',
'PortNumber'
EXEC master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\TerminalServer',
'fDenyTSConnections','REG_DWORD',0;
reg 文件开启远程桌面:
Windows Registry Editor Version 5.00HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TerminalServer]
"fDenyTSConnections"=dword:00000000[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TerminalServer\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
EXEC master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\TerminalServer',
'fDenyTSConnections','REG_DWORD',1;
--By Micropoor