Click here to Skip to main content
15,887,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi im trying to enable or disable windows firewall using javascript by click on a button in a browser. If the firewall is enabled the click should disable the firewall and if it is disabled the click should enable the firewall (simple if statement)

My code is listed below


XML
<html>
<head>
<title>Firewall</title>
</head>

<body>



<script type="text/javascript">


Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile


function fwall()

{


if (objPolicy.FirewallEnabled = TRUE)
  {
  objPolicy.FirewallEnabled = FALSE
  }
else
  {
  objPolicy.FirewallEnabled = TRUE
  }

}

</script>


<button onclick="fwall();">Enable / Disable</button>


</body>
</html>
Posted

1 solution

It's a breach mechanism on others system. Based on what you are trying to do, disabling a firewall on some click just sounds like a step towards a trojan/virus entry.

Wrong forum and wrong people you are asking this. We do not support or encourage anyone in creating virus kind of activity.
 
Share this answer
 
Comments
sg_90 15-May-11 2:53am    
wow paranoid much ??? well this is not for another system ... this is for my own computer .... if you have a problem with this .. than i guess you have problem with my university lecturer who gave out this question!!
Sandeep Mewara 15-May-11 3:04am    
Haha.

Sure, looks like I do have problem with your university lecturer. :)
Did you asked him why such a thing he is after? ;)

BTW, I hope he was not teaching 'How to hack into systems?'
sg_90 15-May-11 3:54am    
no he is teaching a unit called system software which is about operating systems ..... it contains things like threads, memory management...

So things like features of OS were being taught when Active x objects were introduced ... so we were taught scripts ... so the orignal questions was

System Software also encompasses programming techniques that can be used to investigate and modify the configuration of system components. In this section of the assignment, you are required to write a program that lists the network connections available on a Windows operating system of your choice.

which i completed, then the bonus task or follow up question was

Modify your HTML Application so that it turns the Windows Firewall on or off.

Sorry about the detail ... but yea my lecturer is not teaching 'How to hack into systems'.
Richard MacCutchan 15-May-11 3:58am    
Doesn't matter whose system it's for, it would be a serious security breach if the browser allowed it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900