@echo off
net start SessionEnv
net start TermService
::开启服务
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal” “Server /v fDenyTSConnections /t REG_DWORD /d 0 /f
::开启远程选项,打开远程端口
::REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal” “Server /v fDenyTSConnections /t REG_DWORD /d 1 /f
::关闭远程选项,关闭远程端口
::bf68=49000
::修改端口为49000
::REG ADD “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp” /v PortNumber /t REG_DWORD /d 49000 /f
::REG ADD “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp” /v PortNumber /t REG_DWORD /d 49000 /f
::防火墙要么直接关闭,不安全的话启用防火墙就需要放开对应远程端口策略
%1 mshta vbscript:CreateObject(“Shell.Application”).ShellExecute(“cmd.exe”,”/c %~s0 ::”,””,”runas”,1)(window.close)&&exit
::管理员运行
net start MpsSvc
::开启服务
sc config MpsSvc start= auto
::开机启动
netsh advfirewall set allprofiles state on
::启用防火墙
::netsh advfirewall set allprofiles state off
::禁用防火墙
::以下默认放通3389端口,修改了端口需要放开对应端口
netsh advfirewall firewall set rule name = “远程桌面 – 远程监控(TCP-In)” new enable=yes
netsh advfirewall firewall set rule name = “远程桌面 – 用户模式(TCP-In)” new enable=yes
netsh advfirewall firewall set rule name = “远程桌面 – 用户模式(UDP-In)” new enable=yes
::其他端口放通命令
netsh advfirewall firewall set rule name = “远程桌面 – 远程监控(TCP-In)” new enable=yes
netsh advfirewall firewall add rule name=”TCP 49000″ dir=in action=allow protocol=TCP localport=49000
netsh advfirewall firewall add rule name=”UDP 49000″ dir=in action=allow protocol=UDP localport=49000
因为现在windows网上各种教程怎么设置打开都无法访问,用我这个脚本包括服务器也可以访问了。还可以将默认3389端口修改为其他端口,要正常访问先保证网络可达,端口可达,端口不可达可能是防火墙限制原因,放开端口要么关闭防火墙