Jump to content

Help With Enable Firewall.vsb


Recommended Posts

HI,

I new some Help qith this vb Script. Everytime a run this script I receive this windows :

Internet Sharing Configuration

C:\Windows\System32\WScript.exe is attempting to change or view this computer's Internet Conntection Protection settings. To give C:\Windows\System32\WScript.exe permission to edit these settings for as long as the program is opne, click Yes

Someone knows how to run this script without this pop-up?

Thanks

Link to comment
Share on other sites


Try this one:

'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ics/ics/wf_verify_wf_enabled.asp
Option Explicit

'Create Shell object
Dim objShell
set objShell = CreateObject("Shell.Application")

'Declare Firewall variables
Dim fwMgr
Dim profile

'Verify that the SharedAccess service is running. If it isn't, then start it.
If objShell.IsServiceRunning("SharedAccess") = FALSE Then
   objShell.ServiceStart "SharedAccess", TRUE
   'Sleep 1 second to make sure the service is started
   ' before trying to create the objects below. If there
   ' is no sleep, then the script is too fast and the
   ' firewall objects can't be created.
   WScript.Sleep 1000
End If
'WScript.Echo("SharedAccess is running: " & objShell.IsServiceRunning("SharedAccess"))

' Firewall objects have to be created after making sure
' the service is running. If the service isn't running,
' the script will fail.

' Create the firewall manager object.
Set fwMgr = CreateObject("HNetCfg.FwMgr")

' Get the current profile for the local firewall policy.
Set profile = fwMgr.LocalPolicy.CurrentProfile

'Verify that the Firewall is enabled. If it isn't, then enable it.
If profile.FirewallEnabled = FALSE Then
   profile.FirewallEnabled = TRUE
End If
'WScript.Echo("Firewall Enabled: " & profile.FirewallEnabled)

'WScript.Echo("Firewall Exceptions Not Allowed: " & profile.ExceptionsNotAllowed)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...