Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

关于用InternetFirewallEnabled判断是否启用windows防火墙的问题?

10 views
Skip to first unread message

¥¥¥

unread,
Oct 27, 2007, 7:11:00 AM10/27/07
to
您好,在测试微软提供的ISA RQS Script Sample( RQScript.Vbs )时,我遇到一个问题。
脚本中先假设计算机上Windows防火墙已启用(allfw=ture),然后用InternetFirewallEnabled判断是否在具体网络连接上也启用了Windows防火墙?
#######################
Function Check_IsICFEnabled
'--------------------------
' Returns true if all non-VPN connections are firewalled
Const ProgID_NetConLib = "HNetCfg.HNetShare.1" 'hnetcfg.dll
Const NCM_Tunnel = 5 'Mediatype=VPN
Dim connmgr, connlist, conn, connProps, connConfig, allFw
allFw = true
set connmgr = CreateObject(ProgID_NetConLib)
set connlist = connmgr.EnumEveryConnection
for each conn in connlist
set connProps = connmgr.NetConnectionProps(conn)
set connConfig = connmgr.INetSharingConfigurationForINetConnection(conn)
if connProps.MediaType <> NCM_Tunnel then
allFw = allFw and connConfig.InternetFirewallEnabled
end if
next
Check_IsICFEnabled = allFw
End Function
########################################

我的问题是:如何判断计算机上Windows防火墙已启用?
另外,我是一个没有编程经验的脚本初学者。我在读到ProgID_NetConLib =
"HNetCfg.HNetShare.1"时,不知道该怎么查询HNetCfg.HNetShare.1的reference。我搜索到Primitive:
Hnetcfg.dll的页面,可是得不到需要的信息。我该怎么查询到后面的EnumEveryConnection,NetConnectionProps等方法?
Thanks in advance!


jia...@prcvap.microsoft.com

unread,
Oct 29, 2007, 4:27:30 AM10/29/07
to
您好,

关于你的第一个问题,你可以使用FirewallEnabled property 来检测http://msdn2.microsoft.com/en-us/library/aa364717.aspx。或者检测注册表:
HKLM\System\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\
EnableFirewall REG_DWORD 0x00000001(1) 表示enable
若为0则为disable

关于第二个问题,该程序实际上是在使用late binding的方式来创建HNetCfg.HNetShare.1对象 (CreateObject),由于您使用的是vbscript, 所以在接下来的代码中,只需要象在early binding中一样去使用该对象即可。关于HNetCfg.HNetShare.1的引用,windows firewall自身已对该类型进行了注册。

谢谢
葛佳亮

ㄓㄓㄓ

unread,
Nov 26, 2007, 8:17:35 AM11/26/07
to
忘记回复了。已使用FirewallEnabled property解决,谢谢。


passer

unread,
Nov 28, 2009, 1:07:02 AM11/28/09
to
Const ProgID_NetConLib = "HNetCfg.HNetShare.1" 'hnetcfg.dll
Const NCM_Tunnel = 5 'Mediatype=VPN
Dim connmgr, connlist, conn, connProps, connConfig, allFw
allFw = true
set connmgr = CreateObject(ProgID_NetConLib)
set connlist = connmgr.EnumEveryConnection
for each conn in connlist
set connProps = connmgr.NetConnectionProps(conn)
set connConfig = connmgr.INetSharingConfigurationForINetConnection(conn)
if connProps.MediaType <> NCM_Tunnel then
allFw = allFw and connConfig.InternetFirewallEnabled
MSGBOX AllFW
end if
next
Check_IsICFEnabled=allFw


为什么我的这个返回值总是true呢,我就把防火墙取消了也是true????

0 new messages