Click here to Skip to main content
11,927,156 members (51,597 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked

How to enable and disable Windows XP SP2 firewall, programmatically

, 18 Jan 2005
Rate this:
Please Sign up or sign in to vote.
How to programmatically enable and disable Windows XP SP2 firewall.


Since the birth of Windows XP, Microsoft is more proud of its OS. XP is really a robust operating system. After service pack 2 of this product, Microsoft introduced a very good thing called Security Center to increase user security, providing firewall, popup blocker, and etc. All these are very useful to all users. For example, firewall can prevent other applications accessing services like FTP service without permission from users. To access firewall, you can use Firewall’s API, but for those that would like to just enable/disable XP’s firewall.

I wrote an application (with just a few lines of code) to do it!!!

Let’s see how a firewall acts in a system: when user selects “turn on” or “turn off”, it saves information as 1 or 0 in the Registry, under this key:


With a REG_DWORD value named EnableFirewall, 0 means turn off and 1 means turn on! But at this time, if you select “turn off” in Security Center, you will be informed by a red notify icon and balloon text that appears in system, trying to give you this message:

This is because at this time, SVCHOST.EXE, after this change in Registry, will load another application named “wscntfy.exe” belonging to XP SP2, in the system root %system32%. And wscntfy.exe notifies users by this message!!!

If you run your own application changing the EnableFirewall value in Registry, then renaming your application file as “wscntfy.exe”, you have successfully disabled the firewall and users will know nothing about it!!!

I tested my application in latest SP2 updated from Microsoft. My source code is in MFC, a very small application.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Khosrov Boloorian
Web Developer
France France
Khosrov Boloorian is working in Windows system programming, driver and kernel module development

You may also be interested in...

Comments and Discussions

GeneralMy vote of 3 Pin
Mahdi Nejadsahebi17-Feb-12 21:00
groupMahdi Nejadsahebi17-Feb-12 21:00 
Generalgood Pin
Donsw18-Sep-09 7:57
memberDonsw18-Sep-09 7:57 
Generalbatch file is very nice Pin
jhaverimehul3-Feb-07 2:38
memberjhaverimehul3-Feb-07 2:38 
QuestionRegistry may vary! Pin
leojose3-Feb-06 23:54
memberleojose3-Feb-06 23:54 
Generalhelp Pin
gtraiden5-Oct-05 23:00
membergtraiden5-Oct-05 23:00 
GeneralBatch Script Pin
Anonymous25-Apr-05 17:31
sussAnonymous25-Apr-05 17:31 
QuestionHow to open a port or grant rights to an executable programatically? Pin
C a r l18-Jan-05 6:46
memberC a r l18-Jan-05 6:46 
AnswerRe: How to open a port or grant rights to an executable programatically? Pin
Dennis C. Dietrich18-Jan-05 7:09
memberDennis C. Dietrich18-Jan-05 7:09 
GeneralThis is not a bug Pin
Dennis C. Dietrich18-Jan-05 5:26
memberDennis C. Dietrich18-Jan-05 5:26 
GeneralRe: This is not a bug Pin
Anonymous20-May-05 8:26
sussAnonymous20-May-05 8:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151126.1 | Last Updated 19 Jan 2005
Article Copyright 2005 by Khosrov Boloorian
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid