RE: any script to force enable firewall?
Posted: 07-21-2003, 02:51 PM
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
|



Hybrid Mode

