Click here to Skip to main content
13,510,103 members
Click here to Skip to main content
Add your own
alternative version


30 bookmarked
Posted 17 Jan 2005

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 20:00
groupMahdi Nejadsahebi17-Feb-12 20:00 
Generalgood Pin
Donsw18-Sep-09 6:57
memberDonsw18-Sep-09 6:57 
Generalbatch file is very nice Pin
jhaverimehul3-Feb-07 1:38
memberjhaverimehul3-Feb-07 1:38 
QuestionRegistry may vary! Pin
leojose3-Feb-06 22:54
memberleojose3-Feb-06 22:54 
Generalhelp Pin
gtraiden5-Oct-05 22:00
membergtraiden5-Oct-05 22:00 
GeneralBatch Script Pin
Anonymous25-Apr-05 16:31
sussAnonymous25-Apr-05 16:31 
QuestionHow to open a port or grant rights to an executable programatically? Pin
C a r l18-Jan-05 5:46
memberC a r l18-Jan-05 5:46 
AnswerRe: How to open a port or grant rights to an executable programatically? Pin
Dennis C. Dietrich18-Jan-05 6:09
memberDennis C. Dietrich18-Jan-05 6:09 
GeneralThis is not a bug Pin
Dennis C. Dietrich18-Jan-05 4:26
memberDennis C. Dietrich18-Jan-05 4:26 
GeneralRe: This is not a bug Pin
Anonymous20-May-05 7:26
sussAnonymous20-May-05 7: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.

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