<div>With the following code, </div><div><br></div><div><div>def add_firewall_exception():</div><div>        app = win32com.client.gencache.EnsureDispatch(&#39;HNetCfg.FwAuthorizedApplication&#39;, 0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>app.ProcessImageFileName = r&#39;\Python26\python.exe&#39;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>app.Scope = NET_FW_SCOPE_ALL</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>app.IpVersion = NET_FW_IP_VERSION_ANY</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>app.Enabled = True</div>
<div><br></div><div>        firewall_manager = win32com.client.gencache.EnsureDispatch(&#39;HNetCfg.FwMgr&#39;,0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>profile = firewall_manager.LocalPolicy.CurrentProfile</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>profile.AuthorizedApplications.Add(app)</div><div><br></div><div>I get the following error message:</div><div><br></div><div>E:\Documents and Settings\stubby\Desktop&gt;python -OO -i firewall.py</div>
<div>&gt;&gt;&gt; add_firewall_exception()</div><div>Traceback (most recent call last):</div><div>  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;</div><div>  File &quot;firewall.py&quot;, line 41, in add_firewall_exception</div>
<div>    profile.AuthorizedApplications.Add(app)</div><div>  File &quot;E:\python26\lib\site-packages\win32com\gen_py\58FBCF7C-E7A9-467C-80B3-FC65E8FCCA08x0x1x0.py&quot;, line 75, in Add</div><div>    return self._oleobj_.InvokeTypes(2, LCID, 1, (24, 0), ((9, 1),),app</div>
<div>pywintypes.com_error: (-2147352567, &#39;Exception occurred.&#39;, (0, None, None, None, 0, -2147467261), None)</div><div>&gt;&gt;&gt; ^Z</div></div><div><br></div>I&#39;m not at all versed in win32com programming... any help please?<br>
<br><div class="gmail_quote">On Tue, Mar 6, 2012 at 8:05 AM, Bill Tutt <span dir="ltr">&lt;<a href="mailto:bill@tutts.org">bill@tutts.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This sounds more like a problem with your approach to servicing your product, and not necessarily a python windows specific problem. <div><br></div><div>I can point you in the direction to create the firewall exception, but you would still need to figure out how to arrange to have the code actually execute.<div>

<br><div>Windows Firewall rule exceptions don&#39;t appear that hard to define. </div><div><br></div><div><div>Windows Firewall COM interfaces docs:</div></div><div><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366449(v=vs.85).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/windows/desktop/aa366449(v=vs.85).aspx</a></div>

<div><br></div><div>Some simplistic VBScript examples of using those interfaces:</div><div><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366421(v=vs.85).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/windows/desktop/aa366421(v=vs.85).aspx</a></div>

<div><br></div><div>I&#39;d use the VBScript examples as a base and determine what kind of exception is best for your needs. (i.e. as little of an exception as possible)</div><div><br></div><div>Bill</div><div><br><div class="gmail_quote">
<div><div class="h5">
On Mon, Mar 5, 2012 at 9:05 PM, Andrew Hammond <span dir="ltr">&lt;<a href="mailto:andrew.george.hammond@gmail.com" target="_blank">andrew.george.hammond@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
We have python running on a number of devices in the field and have experienced problems where it appears that a windows update has removed a windows firewall exception, blocking our python service from operating.<div><br>


</div><div>Has anyone else experienced something like this? Is there a way to fix it without human intervention?</div><span><font color="#888888"><div><br></div><div>Andrew</div>
</font></span><br></div></div>_______________________________________________<br>
python-win32 mailing list<br>
<a href="mailto:python-win32@python.org" target="_blank">python-win32@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br>
<br></blockquote></div><br></div></div></div>
</blockquote></div><br>