Turns out that I needed to add app.Name = 'Python'
to the code. Ugh. Andrew On Thu, Mar 8, 2012 at 9:22 PM, Mark Hammond <skippy.hamm...@gmail.com>wrote: > As a couple of guesses, I'd ensure you do this from an elevated process > (ie, "run as administrator") and also be sure to use fully-qualified paths. > > (The error code shown appears to be ERROR_INVALID_POINTER, but that might > be a red herring) > > Mark > > > On 9/03/2012 11:16 AM, Andrew Hammond wrote: > >> With the following code, >> >> def add_firewall_exception(): >> app = >> win32com.client.gencache.**EnsureDispatch('HNetCfg.** >> FwAuthorizedApplication', >> 0) >> app.ProcessImageFileName = r'\Python26\python.exe' >> app.Scope = NET_FW_SCOPE_ALL >> app.IpVersion = NET_FW_IP_VERSION_ANY >> app.Enabled = True >> >> firewall_manager = >> win32com.client.gencache.**EnsureDispatch('HNetCfg.FwMgr'**,0) >> profile = firewall_manager.LocalPolicy.**CurrentProfile >> profile.**AuthorizedApplications.Add(**app) >> >> I get the following error message: >> >> E:\Documents and Settings\stubby\Desktop>python -OO -i firewall.py >> >>> add_firewall_exception() >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> File "firewall.py", line 41, in add_firewall_exception >> profile.**AuthorizedApplications.Add(**app) >> File >> "E:\python26\lib\site-**packages\win32com\gen_py\** >> 58FBCF7C-E7A9-467C-80B3-**FC65E8FCCA08x0x1x0.py", >> line 75, in Add >> return self._oleobj_.InvokeTypes(2, LCID, 1, (24, 0), ((9, 1),),app >> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, >> None, None, 0, -2147467261), None) >> >>> ^Z >> >> I'm not at all versed in win32com programming... any help please? >> >> On Tue, Mar 6, 2012 at 8:05 AM, Bill Tutt <b...@tutts.org >> <mailto:b...@tutts.org>> wrote: >> >> This sounds more like a problem with your approach to servicing your >> product, and not necessarily a python windows specific problem. >> >> 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. >> >> Windows Firewall rule exceptions don't appear that hard to define. >> >> Windows Firewall COM interfaces docs: >> http://msdn.microsoft.com/en-**us/library/windows/desktop/** >> aa366449(v=vs.85).aspx<http://msdn.microsoft.com/en-us/library/windows/desktop/aa366449(v=vs.85).aspx> >> >> Some simplistic VBScript examples of using those interfaces: >> http://msdn.microsoft.com/en-**us/library/windows/desktop/** >> aa366421(v=vs.85).aspx<http://msdn.microsoft.com/en-us/library/windows/desktop/aa366421(v=vs.85).aspx> >> >> I'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) >> >> Bill >> >> On Mon, Mar 5, 2012 at 9:05 PM, Andrew Hammond >> <andrew.george.hammond@gmail.**com <andrew.george.hamm...@gmail.com> >> >> <mailto:andrew.george.hammond@**gmail.com<andrew.george.hamm...@gmail.com>>> >> wrote: >> >> 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. >> >> Has anyone else experienced something like this? Is there a way >> to fix it without human intervention? >> >> Andrew >> >> ______________________________**_________________ >> python-win32 mailing list >> python-win32@python.org >> <mailto:python-win32@python.**org<python-win32@python.org> >> > >> >> http://mail.python.org/**mailman/listinfo/python-win32<http://mail.python.org/mailman/listinfo/python-win32> >> >> >> >> >> >> >> ______________________________**_________________ >> python-win32 mailing list >> python-win32@python.org >> http://mail.python.org/**mailman/listinfo/python-win32<http://mail.python.org/mailman/listinfo/python-win32> >> > >
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32