OPTION EXPLICIT
DIM g_oNetSharingManager
DIM g_oEveryConnectionCollection
DIM objArgs
DIM con
Main( )
sub Main( )
WScript.Echo con
Dim oWMIService, oOSCol, oOS, strComputer
strComputer = "."
set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set oOSCol = oWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For each oOS in oOSCol
If ((oOS.Version = "5.1.2600") and (oOS.ServicePackMajorVersion >= 2)) Then<XP SP2かどうかを調べる
Wscript.Quit (FirewallTestSP2 ( ))
else
if Initialize() = TRUE then
set g_oEveryConnectionCollection = g_oNetSharingManager.EnumEveryConnection
Wscript.Quit (FirewallTestAll( ))
end if
end if
Next
end sub
function FirewallTestSP2( )<インターネット接続ファイアウオールのチェック
on error resume next
dim iResult
iResult = 0
dim oFwMgr, oFwPolicy, oFwProfile
dim bFwEnabled, strResult
set oFwMgr = Wscript.CreateObject ("HNetCfg.FwMgr")
set oFwPolicy = oFwMgr.LocalPolicy
set oFwProfile = oFwPolicy.CurrentProfile
bFwEnabled = oFwProfile.FirewallEnabled
If (bFwEnabled) Then
strResult = strResult & "有効"
iResult = 0
Else
strResult = strResult & "無効"
iResult = 1
End If
WScript.Echo (strResult)
FirewallTestSP2 = iResult
end function
function FirewallTestAll( )<Windowsファイアウオールのチェック
on error resume next
dim oItem, oConncetion, oNCProp
dim strConncetionName, strResult
dim bEnabble
dim iMediaType
dim iResult
iResult = 0
bFound = false
for each oItem in g_oEveryConnectionCollection
set oConncetion = g_oNetSharingManager.INetSharingConfigurationForINetConnection(oItem)
set oNCProp = g_oNetSharingManager.NetConnectionProps(oItem)
bEnabble = oConncetion.InternetFirewallEnabled
iMediaType = oNCProp.MediaType
iResult = iResult + 1
strResult = oNCProp.Name & "(" & oNCProp.DeviceName & ", " & iMediaType & "): "
If (bEnabble) Then
strResult = strResult & "有効"
iResult = iResult - 1
Else
strResult = strResult & "無効"
End If
WScript.Echo (strResult) & Chr(13)
next
FirewallTestAll = iResult
end function
function Initialize()
DIM bReturn
bReturn = FALSE
set g_oNetSharingManager = Wscript.CreateObject("HNetCfg.HNetShare.1")
if (IsObject(g_oNetSharingManager)) = FALSE then
Wscript.Echo("Unable to get the HNetCfg.HnetShare.1 object")
else
if (IsNull(g_oNetSharingManager.SharingInstalled) = TRUE) then
Wscript.Echo("Sharing isn't available on this platform.")
else
bReturn = TRUE
end if
end if
Initialize = bReturn
end function
|