English 中文(简体)
VB 文字——如果防火墙能够进行检查
原标题:VBScript - check if firewall is enabled

我写了一封信,在防火墙能够使用的情况下,对Windows进行检查。 它看重的是罚款,但总是说,防火墙是能够做到的,即使它是残疾人。 我花了许多时间分析它,但没有结果——你能否帮助我了解它有什么错误?

Dim strFirewallStatus, strComputer
strComputer = "localhost"

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_ 
                       strComputer & "
ootdefault:StdRegProv")

If err.number = 0 Then
  objReg.GetDWORDValue &H80000002, "SYSTEMCurrentControlSet" &_
  "ServicesSharedAccessParametersFirewallPolicy" &_
  "DomainProfile", "EnableFirewall", dwValue

  If dwValue <> 0 Then
    strFirewallStatus = "Firewall is enabled"
  Else
    strFirewallStatus = "Firewall is disabled"
  End If

  WScript.Echo strFirewallStatus
Else
  WScript.Echo strComputer & " - Error" & err.number & " : " &_
  err.description
  err.clear
End if

我将这本书作为文件保存。

顺便提一下——我如何就系统的启动制定文字? 我希望这一文字在首次发射后自动向登记处补充信息。

最佳回答

You should consider that the Firewall could be enabled/disabled for a Domain Profile, for a Standard Profile (Private or domestic lan) and for a Public Profile (public lan).
Each setting has a separated key in the registry.

如果您的PC不是某一领域的一部分,测试回报作为缺省值,可使用

在我家的PC(677 64bit no area)中,如果不是, 页: 1 标准文件,然后,文字回馈正确无误。

If err.number = 0 Then 
  objReg.GetDWORDValue &H80000002, "SYSTEMCurrentControlSet" &_ 
  "ServicesSharedAccessParametersFirewallPolicy" &_ 
  "StandardProfile", "EnableFirewall", dwValue 
问题回答

暂无回答




相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签