RE: any script to force enable firewall?

Posted: 07-21-2003, 02:51 PM
Dear Customer,

Thank you for your posting.

I understand that you want to enable ICF using a script on all the Windows
XP clients. The following jscript is a sample that will allow one to enable
ICF:

NCCF_FIREWALLED = 0x0400;

Main()

function Main()
{
var objShare = new ActiveXObject("HNetCfg.HNetShare.1");
if (objShare == null)
WScript.Echo("Failed to Create HNetCfg.HNetShare object");
else
GetFirewall(objShare);
return;
}

function GetFirewall(objShare)
{
var objEveryConnection = objShare.EnumEveryConnection;
if (objEveryConnection == null)
WScript.Echo( "Failed to enumerate EveryConnection");
else {
var objEveryEnum = new Enumerator(objEveryConnection);
if (objEveryEnum == null)
WScript.Echo("Failed to create enumerator");
else {
for (objEveryEnum.moveFirst(); !objEveryEnum.atEnd();
objEveryEnum.moveNext())
{
var objNetConnection = objEveryEnum.item();
if (objNetConnection == null)
WScript.Echo ("failed to get NetConnection");
else {
var objNetConnectionProps = objShare.NetConnectionProps(objNetConnection);
if (objNetConnectionProps == null)
WScript.Echo ("Failed to get property")
else {
var str=""
str += "Name: " +objNetConnectionProps.Name;
WScript.Echo(str);
str = "Guid: " +objNetConnectionProps.Guid;
WScript.Echo(str);
str = "Device: " +objNetConnectionProps.DeviceName;
WScript.Echo(str);
str = "Status: " +objNetConnectionProps.Status;
WScript.Echo(str);
str = "MediaType: " +objNetConnectionProps.MediaType;
WScript.Echo(str);


if (objNetConnectionProps.Characteristics & NCCF_FIREWALLED)
WScript.Echo ("Firewall Enabled")
else {
var objShareConfig = objShare.INetSharingConfigurationForINetConnection
(objNetConnection)
WScript.Echo ("Firewall Disbled")
if(objShareConfig != null) {
WScript.Echo ("Enabling Firewall");
objShareConfig.EnableInternetFireWall();
} else {
WScript.Echo("failed to get ShareConfig");
}
}
WScript.Echo("")
}
}
}
}
}
}

In addition, since this is a Development related request and would best be
address in the Developer newsgroups. I have provided the link below:

http://msdn.microsoft.com/newsgroups/default.asp

Hope it clears your concerns.

Thanks and have a good day!

Regards,

Benny Fu
Microsoft Online Partner Support
Microsoft Corporation
Get Secure! – www.microsoft.com/security

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Message-ID: <3F1834AE.55CC1F78@lh.com>
| Date: Sat, 19 Jul 2003 01:55:58 +0800
| From: lh <lh@lh.com>
| X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
| X-Accept-Language: en
| MIME-Version: 1.0
| Subject: any script to force enable firewall?
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Newsgroups: microsoft.public.windowsxp.network_web
| NNTP-Posting-Host: cm218-252-208-192.hkcable.com.hk 218.252.208.192
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.windowsxp.network_web:119830
| X-Tomcat-NG: microsoft.public.windowsxp.network_web
|
| Hi all,
| Does any solution to force enable xp internal firewall in every logon?
| either by logon script or GPO.
|
| thx
|

Reply With Quote

Responses to "RE: any script to force enable firewall?"

 
LinkBack Thread Tools Display Modes
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automated Enable of XP Firewall after Sysprep Christopher Hota Windows XP Help & Support 2 08-06-2003 12:13 AM
way to enable xp built in firewall but still act on the LAN. signit Windows XP Security & Administration 0 07-18-2003 06:45 PM
XP Firewall will not enable Brian Amonn Windows XP Network & Web 6 07-13-2003 10:36 PM
script disable/enable local area connections Tony Windows XP Network & Web 1 07-13-2003 04:58 PM
Cannot enable Internet Connection Firewall Mark Jones Windows XP Security & Administration 3 07-02-2003 02:54 AM