Jump to content

Start/Stop Windows Firewall (XPSP2)


 Share

Recommended Posts

Here is a quick script I wrote for a user here on our work LAN. It's basically a quick GUI to start/stop the Windows Firewall included with XP SP2.

Just throwing this out there in case anybody else can use it. If you find a better way to do something in the script, be sure to let me know, I love learning from my mistakes.

You need ServiceControl.au3 from here: ServiceControl.au3

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.2.0
 Author:         John May

 Script Function:
    Script to stop the windows firewall.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIConstants.au3>
#include <ServiceControl.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Windows Firewall", 194, 132, 274, 133)
$Label1 = GUICtrlCreateLabel("Windows Firewall is currently:", 24, 8, 142, 17)
$Status = GUICtrlCreateLabel("Status", 72, 32, 58, 17)
$Start = GUICtrlCreateButton("Start", 16, 56, 73, 25, 0)
$Stop = GUICtrlCreateButton("Stop", 104, 56, 73, 25, 0)
$ExitBtn = GUICtrlCreateButton("Exit", 56, 88, 73, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;======  Main code begins here ======;
_Startup()

While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $Start
            If _ServiceExists("", "SharedAccess") Then
                GUICtrlSetColor($Status, 0x000000)
                GUICtrlSetData($Status, "Starting...")
                _StartService("", "SharedAccess")
                Sleep(2000)
                GUICtrlSetColor($Status, 0x008000)
                GUICtrlSetData($Status, "Started")
            EndIf
            
        Case $Stop
            If _ServiceExists("", "SharedAccess") Then
                GUICtrlSetColor($Status, 0x000000)
                GUICtrlSetData($Status, "Stopping...")
                _StopService("", "SharedAccess")
                Sleep(2000)
                GUICtrlSetColor($Status, 0xff0000)
                GUICtrlSetData($Status, "Stopped")
            EndIf
            
        Case $ExitBtn
            Exit

    EndSwitch
WEnd

Func _StartUp()
    If _ServiceExists("", "SharedAccess") Then
        ;MsgBox(262208, "Status", _ServiceRunning("", "SharedAccess"))
        If _ServiceRunning("", "SharedAccess") = 1 Then
            GUICtrlSetColor($Status, 0x008000)
            GUICtrlSetData($Status, "Started")
        ElseIf _ServiceRunning("", "SharedAccess") = 0 Then
            GUICtrlSetData($Status, "Stopped")
            GUICtrlSetColor($Status, 0xff0000)
        EndIf
    EndIf
EndFunc
Link to comment
Share on other sites

Im not sure but unless they are in the tech department(which maybe they are) are they supposed to turn it off? of is that the point of this script?

The firewall is off by default on our domain, but on when they aren't on the domain, for example, laptops. I created this app for those people with laptops on our network that would turn off the firewall. We have certain applications that initiate a reverse connection to the computer and when the firewall is on, the application won't run, so the need for this program.

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
 Share

  • Recently Browsing   0 members

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