通过修改注册表打开或关闭Windows防火墙端口

通过修改注册表打开或关闭Windows防火墙端口,以远程桌面端口3389为例:

SetPort.bat

@echo off
SET TS="HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server"
SET LIST="HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters
SET LIST=%LIST%\FirewallPolicy\StandardProfile\GloballyOpenPorts\List"

:: 打开3389端口
IF [%1]==[TRUE] (
   ECHO %TS%
   ECHO %LIST%
   reg add %TS% /v fDenyTSConnections /t REG_DWORD /d 0 /f
   reg add %LIST% /v "3389:TCP" /t REG_SZ /d "3389:TCP:*:Enabled:@xpsp2res.dll,-22009" /f
   ECHO Enable Remote Desktop OK!
   GOTO END
)

:: 关闭3389端口
IF [%1]==[FALSE] (
   ECHO %TS%
   ECHO %LIST%
   reg add %TS% /v fDenyTSConnections /t REG_DWORD /d 1 /f
   reg add %LIST% /v "3389:TCP" /t REG_SZ /d "3389:TCP:*:Disabled:@xpsp2res.dll,-22009" /f
   ECHO Disable Remote Desktop OK!
   GOTO END
)

:END

 本文地址:http://www.cnblogs.com/anjou/archive/2007/01/23/628227.html

posted on 2007-01-23 18:56  大豆男生  阅读(8237)  评论(3编辑  收藏  举报

导航