Click here to Skip to main content
6,822,613 members and growing! (19,475 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Win32/64 SDK & OS » General     Intermediate

How to enable and disable Windows XP SP2 firewall, programmatically

By Khosrov Boloorian

How to programmatically enable and disable Windows XP SP2 firewall.
VC7.1, Windows, MFC, VS.NET2003, Dev
Posted:18 Jan 2005
Updated:18 Jan 2005
Views:118,627
Bookmarked:27 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
18 votes for this article.
Popularity: 3.28 Rating: 2.61 out of 5
6 votes, 33.3%
1

2
4 votes, 22.2%
3
3 votes, 16.7%
4
5 votes, 27.8%
5

Introduction

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:

HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\ 
                            Parameters\FirewallPolicy\StandardProfile

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.

License

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


Member
Khosrov Boloorian is working in Windows system programming, driver and kernel module development

Occupation: Web Developer
Location: France France

Other popular Win32/64 SDK & OS articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 9 of 9 (Total in Forum: 9) (Refresh)FirstPrevNext
Generalgood PinmemberDonsw7:57 18 Sep '09  
Generalbatch file is very nice Pinmemberjhaverimehul2:38 3 Feb '07  
QuestionRegistry may vary! Pinmemberleojose23:54 3 Feb '06  
Generalhelp Pinmembergtraiden23:00 5 Oct '05  
GeneralBatch Script PinsussAnonymous17:31 25 Apr '05  
GeneralHow to open a port or grant rights to an executable programatically? PinmemberC a r l6:46 18 Jan '05  
GeneralRe: How to open a port or grant rights to an executable programatically? PinmemberDennis C. Dietrich7:09 18 Jan '05  
GeneralThis is not a bug PinmemberDennis C. Dietrich5:26 18 Jan '05  
GeneralRe: This is not a bug PinsussAnonymous8:26 20 May '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

PermaLink | Privacy | Terms of Use
Last Updated: 18 Jan 2005
Editor: Smitha Vijayan
Copyright 2005 by Khosrov Boloorian
Everything else Copyright © CodeProject, 1999-2010
Web09 | Advertise on the Code Project