[python-win32] How to disable Windows Firewall using WMI
prashant padaganur
prashantpadaganur at gmail.com
Fri Jul 6 14:54:31 CEST 2012
Hi,
I am trying to disable the Windows Firewall using WMI. Below is the code.
When I am running the VBscript I am not getting any errors. But my python
script is coming out with some COM errors. (pasted below)
Am I doing something wrong? Here is the code.
<code>
import wmi,os
c = wmi.WMI("WinMgmts:\root\Microsoft\HomeNet")
for obj in c.HNet_ConnectionProperties():
print obj
print obj.IsFirewalled
obj.IsFirewalled = 'False'
obj.Put_()
#Equivalent VB code
'''
Set WMI = GetObject("WinMgmts:\root\Microsoft\HomeNet")
Set Objs = WMI.InstancesOf("HNet_ConnectionProperties")
For Each Obj In Objs
Obj.IsFirewalled = False
Obj.Put_
Next
'''
</code>
----------
Errors:
----------
Traceback (most recent call last):
File "C:/Users/ppadagax/Documents/Scripts/firewall.py", line 3, in
<module>
c = wmi.WMI("WinMgmts:\root\Microsoft\HomeNet")
File "C:\Python27\lib\site-packages\wmi.py", line 1290, in connect
handle_com_error ()
File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error
raise klass (com_error=err)
x_wmi: <x_wmi: Unexpected COM Error (-2147217375, 'OLE error 0x80041021',
None, None)>
--
Cheers,
Prashant G.P
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120706/e35a1bad/attachment.html>
More information about the python-win32
mailing list