From damienmoloney at gmail.com Sun Jun 3 07:21:45 2012 From: damienmoloney at gmail.com (damien moloney) Date: Sun, 3 Jun 2012 15:21:45 +1000 Subject: [python-win32] python-win32 Digest, Vol 110, Issue 30 In-Reply-To: References: Message-ID: Win32 file properties The code under the https://github.com/tjguk/winshell was very helpful, I'm able to retrieve the values. You are correct delving into how it all works it is very complicated. Thanks Damien. On 29 May 2012 20:00, wrote: > Send python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > > > Today's Topics: > > 1. Re: Retrieve file property values (Tim Golden) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 28 May 2012 15:19:14 +0100 > From: Tim Golden > Cc: python-win32 at python.org > Subject: Re: [python-win32] Retrieve file property values > Message-ID: <4FC38962.5070002 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1 > > On 27/05/2012 11:54, damien moloney wrote: > > Hi, > > > > Have been unable to retrieve the windows file properties/attributes > > under "Subject", and "Description". for .msi files on a Win XP c using > > win32api. Have been able to get version type info, > > but unable to get much more. I came across the following "fromwin32com > > importstoragecon # constants related to storage functions." which looked > > promising but fell over as the .msi files I was looking at are not > > "storage files". Any ides on where next. > > This is a bit more complicated than you might like. I have > a half-hearted example here: > > > http://timgolden.me.uk/python/win32_how_do_i/get-document-summary-info.html > > and the in-dev version of my winshell module includes some more > general-purpose code which you might at least want to look at > even though it's not 100% at the moment: > > https://github.com/tjguk/winshell > > Part of the difficulty is that Windows has switched between two > approaches to this area which doesn't help when trying to get > examples. > > TJG > > > ------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of python-win32 Digest, Vol 110, Issue 30 > ********************************************* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From radekholypublic at gmail.com Fri Jun 15 09:53:28 2012 From: radekholypublic at gmail.com (=?ISO-8859-1?Q?Radek_Hol=FD?=) Date: Fri, 15 Jun 2012 09:53:28 +0200 Subject: [python-win32] BCD WMI modification via pywin32 without effect In-Reply-To: References: Message-ID: Hello, I?m trying to edit the BCD (Boot Configuration Data) using WMI in Python: >>> import sys >>> import win32com.client >>> >>> def call(object, name, *args): ... method = object.Methods_(name) ... params = method.InParameters ... for param, arg in zip(params.Properties_, args): ... param.Value = arg ... result = object.ExecMethod_(name, params) ... return [param.Value for param in result.Properties_] ... >>> objBCD = win32com.client.GetObject("winmgmts:{impersonationlevel=Impersonate,(Backup,Restore)}!root/wmi:BcdStore") >>> success, objBcdStore = call(objBCD, "OpenStore", "") >>> if not success: ... sys.exit(1) ... >>> del objBCD >>> objWBM, success = call(objBcdStore, "OpenObject", "{9dea862c-5cdd-4e70-acc1-f32b344d4795}") >>> if not success: ... sys.exit(1) ... >>> success, = call(objWBM, "SetIntegerElement", 0x25000004, 5) >>> if not success: ... sys.exit(1) ... >>> objElement, success = call(objWBM, "GetElement", 0x25000004) >>> if not success: ... sys.exit(1) ... >>> print(objElement.Properties_("Integer").Value) This code has no effect (it does not change the value of element "0x25000004"), although the equivalent in VB works as expected: >>> dim objBCD >>> dim objBCDStore >>> dim objWBM >>> dim objElement >>> >>> set objBCD = GetObject("winmgmts:{impersonationlevel=Impersonate,(Backup,Restore)}!root/wmi:BcdStore") >>> >>> if Err.number <> 0 then ... WScript.Quit(1) ... end if >>> >>> if not objBCD.OpenStore( "", objBcdStore ) then ... WScript.Quit(1) ... end if >>> >>> set objBCD = nothing >>> >>> if not objBcdStore.OpenObject( "{9dea862c-5cdd-4e70-acc1-f32b344d4795}", objWBM ) then ... WScript.Quit(1) ... end if >>> >>> if not objWBM.SetIntegerElement( &h25000004, 10 ) then ... WScript.Quit(1) ... end if >>> >>> if not objWBM.GetElement( &h25000004, objElement ) then ... WScript.Quit(1) ... end if >>> >>> WScript.Echo objElement.Integer I execute both scripts from elevated command line. Can you please help? Thank you -- Radek Hol? Czech republic From mail at timgolden.me.uk Fri Jun 15 14:54:39 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 15 Jun 2012 13:54:39 +0100 Subject: [python-win32] BCD WMI modification via pywin32 without effect In-Reply-To: References: Message-ID: <4FDB308F.5050601@timgolden.me.uk> On 15/06/2012 08:53, Radek Hol? wrote: > Hello, > > I?m trying to edit the BCD (Boot Configuration Data) using WMI in Python: Hmmm. I'd love to help you, but I'd need to set up a VM first so I don't screw up my Boot Configuration along the way! I notice one small line in the docs for BcdIntegerElement: http://msdn.microsoft.com/en-us/library/windows/desktop/aa362650%28v=vs.85%29.aspx which states: """ The value is passed as a string because Automation does not natively support 64-bit integers """ Frankly if that *were* the issue, I'd expect the Set... call to fail in the presence of integer but it's the only thing I can spot quickly. BTW my wmi module does some of the heavy lifting, but it would need some help here as the methods you're using are (unusually) returning further WMI objects. I don't think it'll help the issue you're experiencing but it might be worth a glance: http://timgolden.me.uk/python/wmi/index.html TJG From ferdinandsousa at gmail.com Fri Jun 15 18:20:26 2012 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Fri, 15 Jun 2012 21:50:26 +0530 Subject: [python-win32] Installing pywin32 for Python 2.7 AMD64 Message-ID: Hi List, First off, it's good to be back after 3 years!! I was dusting off some old scripts I had written using pywin32. (Python 2.5 era I think). It uses the win32con and win32api modules. Now I'm trying to use the same scripts with Python 2.7 AMD64 version. I downloaded pywin32-217.win-amd64-py2.7.exe from the sourceforge site and installed it. At the end, I see the following message: ---------------------------------------------------------------------------------------------- Postinstall script finished Click the Finish button to exit the setup wizard close failed in file object destructor: sys.excepthook is missing lost sys.stderr ---------------------------------------------------------------------------------------------- Then, I tried importing win32con and it works. But, when I tried importing win32api, win32gui I get the error message: ---------------------------------------------------------------------------------------------- Traceback (most recent call last): File "", line 1, in import win32api, win32gui ImportError: DLL load failed: The specified module could not be found. ---------------------------------------------------------------------------------------------- So I uninstalled pywin32 and tried installing it from source. But alas, I again hit a roadblock: ---------------------------------------------------------------------------------------------- C:\Users\ferdinand\Downloads\pywin32-217>c:\Python27\python.exe setup.py install Building pywin32 2.7.217.0 Traceback (most recent call last): File "setup.py", line 1944, in """ % dirs).split(), File "setup.py", line 603, in __init__ if os.path.isfile(os.path.join(sdk_dir, "include", "activdbg.h")): File "c:\Python27\lib\ntpath.py", line 96, in join assert len(path) > 0 TypeError: object of type 'NoneType' has no len() C:\Users\ferdinand\Downloads\pywin32-217> ---------------------------------------------------------------------------------------------- Any pointers? Thanks in advance, Ferdi -------------- next part -------------- An HTML attachment was scrubbed... URL: From radekholypublic at gmail.com Fri Jun 15 19:57:39 2012 From: radekholypublic at gmail.com (=?ISO-8859-1?Q?Radek_Hol=FD?=) Date: Fri, 15 Jun 2012 19:57:39 +0200 Subject: [python-win32] BCD WMI modification via pywin32 without effect In-Reply-To: <4FDB308F.5050601@timgolden.me.uk> References: <4FDB308F.5050601@timgolden.me.uk> Message-ID: 2012/6/15 Tim Golden : > On 15/06/2012 08:53, Radek Hol? wrote: >> Hello, >> >> I?m trying to edit the BCD (Boot Configuration Data) using WMI in Python: > > Hmmm. I'd love to help you, but I'd need to set up a VM first so I don't > screw up my Boot Configuration along the way! > > I notice one small line in the docs for BcdIntegerElement: > > > http://msdn.microsoft.com/en-us/library/windows/desktop/aa362650%28v=vs.85%29.aspx > > which states: > > """ > The value is passed as a string because Automation does not natively > support 64-bit integers > """ > > Frankly if that *were* the issue, I'd expect the Set... call to fail > in the presence of integer but it's the only thing I can spot quickly. > > BTW my wmi module does some of the heavy lifting, but it would need some > help here as the methods you're using are (unusually) returning further > WMI objects. I don't think it'll help the issue you're experiencing but > it might be worth a glance: > > ?http://timgolden.me.uk/python/wmi/index.html > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 I found a small discrepancy in my previously mentioned VBS. But still the VBS works and the Python script does not work. Instead of this: >>> if not objWBM.SetIntegerElement( &h25000004, 10 ) then there should be this: >>> if not objWBM.SetIntegerElement( &h25000004, 5 ) then I must confess that my script uses your WMI module. In fact, it looks like this: >>> import wmi >>> import sys >>> class_ = wmi.WMI(computer=".", impersonation_level="Impersonate", privileges=("Backup", "Restore"), namespace="WMI", suffix="BcdStore") >>> success, store_com = class_.OpenStore("") >>> if not success: ... sys.exit(1) >>> >>> store = wmi._wmi_object(store_com) >>> manager_com, success = store.OpenObject("{9dea862c-5cdd-4e70-acc1-f32b344d4795}") >>> if not success: ... sys.exit(1) >>> >>> manager = wmi._wmi_object(manager_com) >>> success, = manager.SetIntegerElement(0x25000004, "5") >>> if not success: ... sys.exit(1) >>> >>> element_com, success = manager.GetElement(0x25000004) >>> if not success: ... sys.exit(1) >>> >>> element = wmi._wmi_object(element_com) >>> print(element.Integer) But because I am writing to this mail group, I rewrote it to use only ``win32com`` functions (wrapped by your module). I read the notice about passing the value as a ``string``. I tried to pass both ``string`` and ``integer`` and neither one worked. BTW: The script only sets the timeout for the operating system selection, so it should be safe. -- Radek Hol? Czech republic From rupole at hotmail.com Fri Jun 15 22:14:04 2012 From: rupole at hotmail.com (Roger Upole) Date: Fri, 15 Jun 2012 16:14:04 -0400 Subject: [python-win32] BCD WMI modification via pywin32 without effect References: Message-ID: Looks like the parameters to SetIntegerElement are reversed: >>> objWBM.Methods_('SetIntegerElement').InParameters.Properties_[0].Name 'Integer' >>> objWBM.Methods_('SetIntegerElement').InParameters.Properties_[1].Name 'Type' If I switch the call to success, = call(objWBM, "SetIntegerElement", 5, 0x25000004) the expected value is printed. Roger From mail at timgolden.me.uk Fri Jun 15 23:02:54 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 15 Jun 2012 22:02:54 +0100 Subject: [python-win32] BCD WMI modification via pywin32 without effect In-Reply-To: References: Message-ID: <4FDBA2FE.2030906@timgolden.me.uk> On 15/06/2012 21:14, Roger Upole wrote: > Looks like the parameters to SetIntegerElement are reversed: > >>>> objWBM.Methods_('SetIntegerElement').InParameters.Properties_[0].Name > 'Integer' >>>> objWBM.Methods_('SetIntegerElement').InParameters.Properties_[1].Name > 'Type' > > If I switch the call to > success, = call(objWBM, "SetIntegerElement", 5, 0x25000004) > the expected value is printed. Good catch. To the OP: if you use named params on the wmi methods rather than positional this will avoid the issue. TJG From mattl at google.com Fri Jun 15 23:43:43 2012 From: mattl at google.com (Matt LaPlante) Date: Fri, 15 Jun 2012 16:43:43 -0500 Subject: [python-win32] win32com.adsi limits number of members returned Message-ID: Using the following code... import win32com.adsi DNC=win32com.adsi.ADsGetObject('LDAP://rootDSE').Get('DefaultNamingContext') path = 'LDAP://cn=BIG_GROUP,ou=Groups,'+DNC groupobj = win32com.adsi.ADsGetObject(path) users = groupobj.member print len(users) The output is always a maximum 1500, even if BIG_GROUP contains several thousand members. How can I execute this query in a way that returns all members of BIG_GROUP? From radekholypublic at gmail.com Fri Jun 15 23:55:31 2012 From: radekholypublic at gmail.com (=?ISO-8859-1?Q?Radek_Hol=FD?=) Date: Fri, 15 Jun 2012 23:55:31 +0200 Subject: [python-win32] BCD WMI modification via pywin32 without effect In-Reply-To: References: Message-ID: 2012/6/15 Roger Upole : > Looks like the parameters to SetIntegerElement are reversed: > >>>> objWBM.Methods_('SetIntegerElement').InParameters.Properties_[0].Name > 'Integer' >>>> objWBM.Methods_('SetIntegerElement').InParameters.Properties_[1].Name > 'Type' > > If I switch the call to > success, = call(objWBM, "SetIntegerElement", 5, 0x25000004) > the expected value is printed. > > ?Roger > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 Wow, what a surprise. I did not expect that. I feel stupid that I did not come out. :-[ I?m solving it for three days in a row... In the Microsoft?s documentation (and in Visual Basic) it is reversed. Thank you very much for your help! -- Radek Hol? Czech republic From mail at timgolden.me.uk Sat Jun 16 06:12:23 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 16 Jun 2012 05:12:23 +0100 Subject: [python-win32] win32com.adsi limits number of members returned In-Reply-To: References: Message-ID: <4FDC07A7.2030104@timgolden.me.uk> On 15/06/2012 22:43, Matt LaPlante wrote: > Using the following code... > > import win32com.adsi > DNC=win32com.adsi.ADsGetObject('LDAP://rootDSE').Get('DefaultNamingContext') > path = 'LDAP://cn=BIG_GROUP,ou=Groups,'+DNC > groupobj = win32com.adsi.ADsGetObject(path) > users = groupobj.member > print len(users) > > The output is always a maximum 1500, even if BIG_GROUP contains > several thousand members. How can I execute this query in a way that > returns all members of BIG_GROUP? (Sorry, quick answer for now just to set on the right route.) This is a built-in limitation. I can't get a web connection at the moment but if you search MSDN for "attribute range retrieval" you should find a description. In principle you could use GetInfoEx but at present it's not implemented in the pywin32 ADSI code. Instead you might craft your LDAP query with a range qualifier to see if that worked. TJG From mail at timgolden.me.uk Sat Jun 16 06:17:53 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 16 Jun 2012 05:17:53 +0100 Subject: [python-win32] BCD WMI modification via pywin32 without effect In-Reply-To: References: Message-ID: <4FDC08F1.8030809@timgolden.me.uk> On 15/06/2012 22:55, Radek Hol? wrote: > 2012/6/15 Roger Upole: >> Looks like the parameters to SetIntegerElement are reversed: >> >>>>> objWBM.Methods_('SetIntegerElement').InParameters.Properties_[0].Name >> 'Integer' >>>>> objWBM.Methods_('SetIntegerElement').InParameters.Properties_[1].Name >> 'Type' >> >> If I switch the call to >> success, = call(objWBM, "SetIntegerElement", 5, 0x25000004) >> the expected value is printed. >> >> Roger > > Wow, what a surprise. I did not expect that. I feel stupid that I did > not come out. :-[ I?m solving it for three days in a row... In the > Microsoft?s documentation (and in Visual Basic) it is reversed. > > Thank you very much for your help! In fact, since you're already using the wmi module, you can see the correct order of parameters via the method's repr: import wmi print wmi.WMI (namespace="wmi").BCDObject.SetIntegerElement # (ReturnValue)> TJG From radekholypublic at gmail.com Sat Jun 16 08:22:09 2012 From: radekholypublic at gmail.com (=?ISO-8859-1?Q?Radek_Hol=FD?=) Date: Sat, 16 Jun 2012 08:22:09 +0200 Subject: [python-win32] BCD WMI modification via pywin32 without effect In-Reply-To: <4FDC08F1.8030809@timgolden.me.uk> References: <4FDC08F1.8030809@timgolden.me.uk> Message-ID: 2012/6/16 Tim Golden : > On 15/06/2012 22:55, Radek Hol? wrote: >> >> 2012/6/15 Roger Upole: >>> >>> Looks like the parameters to SetIntegerElement are reversed: >>> >>>>>> objWBM.Methods_('SetIntegerElement').InParameters.Properties_[0].Name >>> >>> 'Integer' >>>>>> >>>>>> objWBM.Methods_('SetIntegerElement').InParameters.Properties_[1].Name >>> >>> 'Type' >>> >>> If I switch the call to >>> success, = call(objWBM, "SetIntegerElement", 5, 0x25000004) >>> the expected value is printed. >>> >>> ?Roger >> >> >> Wow, what a surprise. I did not expect that. I feel stupid that I did >> not come out. :-[ I?m solving it for three days in a row... In the >> Microsoft?s documentation (and in Visual Basic) it is reversed. >> >> Thank you very much for your help! > > > > In fact, since you're already using the wmi module, you can see the correct > order of parameters via the method's repr: > > > import wmi > > print wmi.WMI (namespace="wmi").BCDObject.SetIntegerElement > # (ReturnValue)> > > > > TJG > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 Yes, I know, but I did not realize to doubt about Microsoft's documentation and its validity in Python implementation. In the future I will be more vigilant. Thank you very much, -- Radek Hol? Czech republic From radekholypublic at gmail.com Sun Jun 17 21:34:34 2012 From: radekholypublic at gmail.com (=?ISO-8859-1?Q?Radek_Hol=FD?=) Date: Sun, 17 Jun 2012 21:34:34 +0200 Subject: [python-win32] How to find corresponding WMI/COM object for given Windows Registry key? Message-ID: Hello, I'm playing with pywin32 and wmi modules last week. During my experiments I found some attribute/method of some object (COMObject/_wmi_object) or its property which listed the Windows Registry key path which is set by the object. Don?t you know which object/attribute it was? Don?t you know how to find corresponding WMI/COM object for given Windows Registry key? Is there any useful table of this mapping on the web? Thank you very much -- Radek Hol? Czech republic From mail at timgolden.me.uk Sun Jun 17 23:45:54 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 17 Jun 2012 22:45:54 +0100 Subject: [python-win32] How to find corresponding WMI/COM object for given Windows Registry key? In-Reply-To: References: Message-ID: <4FDE5012.8090801@timgolden.me.uk> On 17/06/2012 20:34, Radek Hol? wrote: > Hello, > > I'm playing with pywin32 and wmi modules last week. During my > experiments I found some attribute/method of some object > (COMObject/_wmi_object) or its property which listed the Windows > Registry key path which is set by the object. > Don?t you know which object/attribute it was? > > Don?t you know how to find corresponding WMI/COM object for given > Windows Registry key? Is there any useful table of this mapping on the > web? > > Thank you very much import wmi reg = wmi.WMI (namespace="default").StdRegProv reg.EnumKey (...) # etc. BTW -- not that this answers your question -- did you see that there's a mini-webapp which comes with the wmi distribution called wmiweb.py? It gives an easy way to browse the WMI namespaces? It has no search capability to it wouldn't have helped much with this question unless you could remember which namespace it was in but in case you're experimenting elsewhere.... TJG From radekholypublic at gmail.com Mon Jun 18 01:58:02 2012 From: radekholypublic at gmail.com (=?ISO-8859-1?Q?Radek_Hol=FD?=) Date: Mon, 18 Jun 2012 01:58:02 +0200 Subject: [python-win32] How to find corresponding WMI/COM object for given Windows Registry key? In-Reply-To: <4FDE5012.8090801@timgolden.me.uk> References: <4FDE5012.8090801@timgolden.me.uk> Message-ID: 2012/6/17 Tim Golden : > On 17/06/2012 20:34, Radek Hol? wrote: >> >> Hello, >> >> I'm playing with pywin32 and wmi modules last week. During my >> experiments I found some attribute/method of some object >> (COMObject/_wmi_object) or its property which listed the Windows >> Registry key path which is set by the object. >> Don?t you know which object/attribute it was? >> >> Don?t you know how to find corresponding WMI/COM object for given >> Windows Registry key? Is there any useful table of this mapping on the >> web? >> >> Thank you very much > > > > import wmi > > reg = wmi.WMI (namespace="default").StdRegProv > > reg.EnumKey (...) # etc. > > > > > BTW -- not that this answers your question -- did you see that > there's a mini-webapp which comes with the wmi distribution > called wmiweb.py? > > It gives an easy way to browse the WMI namespaces? It has no > search capability to it wouldn't have helped much with this > question unless you could remember which namespace it was in > but in case you're experimenting elsewhere.... > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 My question is probably poorly formulated. In fact -- as I discovered -- some WMI objects reflect their values in the Windows Registry keys (for example there is mapping ?root\cimv2:Win32_OSRecoveryConfiguration.AutoReboot? in ?HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl\AutoReboot?). Is there some *common* attribute of WMI/COM/OLE objects giving the key path? Is it possible to determine (by some manual/automatic iteration), for example which WMI/COM object sets ?HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\VerboseStatus?? I must say that wmiweb is a great application. Thank you -- Radek Hol? Czech republic From skippy.hammond at gmail.com Mon Jun 18 06:12:27 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 18 Jun 2012 14:12:27 +1000 Subject: [python-win32] Installing pywin32 for Python 2.7 AMD64 In-Reply-To: References: Message-ID: <4FDEAAAB.6090900@gmail.com> On 16/06/2012 2:20 AM, Ferdinand Sousa wrote: > Hi List, > > First off, it's good to be back after 3 years!! > > I was dusting off some old scripts I had written using pywin32. (Python > 2.5 era I think). It uses the win32con and win32api modules. > > Now I'm trying to use the same scripts with Python 2.7 AMD64 version. > > I downloaded pywin32-217.win-amd64-py2.7.exe from the sourceforge site > and installed it. At the end, I see the following message: > ---------------------------------------------------------------------------------------------- > Postinstall script finished > Click the Finish button to exit the setup wizard > > close failed in file object destructor: > sys.excepthook is missing > lost sys.stderr > ---------------------------------------------------------------------------------------------- This seems to happen if User Access Control (UAC) is disabled - is it disabled for you? Either way, try running "python scripts\pywin32_postinstall.py -install" from the root of the install directory and things should finish registering - that should fix the next error you see. > > Then, I tried importing win32con and it works. But, when I tried > importing win32api, win32gui I get the error message: > > ---------------------------------------------------------------------------------------------- > Traceback (most recent call last): > File "", line 1, in > import win32api, win32gui > ImportError: DLL load failed: The specified module could not be found. > ---------------------------------------------------------------------------------------------- > > So I uninstalled pywin32 and tried installing it from source. But alas, > I again hit a roadblock: > > ---------------------------------------------------------------------------------------------- > C:\Users\ferdinand\Downloads\pywin32-217>c:\Python27\python.exe setup.py > install > Building pywin32 2.7.217.0 > Traceback (most recent call last): > File "setup.py", line 1944, in > """ % dirs).split(), > File "setup.py", line 603, in __init__ > if os.path.isfile(os.path.join(sdk_dir, "include", "activdbg.h")): > File "c:\Python27\lib\ntpath.py", line 96, in join > assert len(path) > 0 > TypeError: object of type 'NoneType' has no len() This will probably be due to the setup script not finding the platform SDK. HTH, Mark > > C:\Users\ferdinand\Downloads\pywin32-217> > ---------------------------------------------------------------------------------------------- > > Any pointers? > > Thanks in advance, > Ferdi > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mail at timgolden.me.uk Mon Jun 18 06:54:44 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 18 Jun 2012 05:54:44 +0100 Subject: [python-win32] How to find corresponding WMI/COM object for given Windows Registry key? In-Reply-To: References: <4FDE5012.8090801@timgolden.me.uk> Message-ID: <4FDEB494.10406@timgolden.me.uk> On 18/06/2012 00:58, Radek Hol? wrote: > My question is probably poorly formulated. > In fact -- as I discovered -- some WMI objects reflect their values in > the Windows Registry keys (for example there is mapping > ?root\cimv2:Win32_OSRecoveryConfiguration.AutoReboot? in > ?HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl\AutoReboot?). > Is there some *common* attribute of WMI/COM/OLE objects giving the key path? I don't believe so. The thing about WMI is that it provides a uniform and accessible layer on top of quite a lot of lower-level APIs. In some cases, that's a layer over registry entries; in other cases it's a layer over an actual API call. It may even be the only publicly-accessible means of achieving some result. As it happens, for *methods* there is sometimes a clue as to the underlying API. I have exposed this as (for want of a better name) the provenance attribute of a method class. So if you do this: import wmi print wmi.WMI().Win32_Process.Create.provenance You'll see something like this: Win32API|Process and Thread Functions|CreateProcess I'm not aware of any such thing for attributes, although it wouldn't surprise me utterly if there were. > > I must say that wmiweb is a great application. Thanks; I rather like it myself :) TJG From mc at mclaveau.com Mon Jun 18 07:37:05 2012 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 18 Jun 2012 07:37:05 +0200 Subject: [python-win32] Thanks to M Hammond for Pywin.217 In-Reply-To: <4FDEAAAB.6090900@gmail.com> References: <4FDEAAAB.6090900@gmail.com> Message-ID: <6CAA1111FEBC4F319147479581902B89@M14> Hi! Sorry for delay, but since several months, I can't post via the python-win32 mailing list. I am very happy with Pywin32 217 ; all my old problems are solved with this release. M. Hammond, thanks very much!!! -- Michel Claveau -------------- next part -------------- An HTML attachment was scrubbed... URL: From radekholypublic at gmail.com Mon Jun 18 09:12:17 2012 From: radekholypublic at gmail.com (=?ISO-8859-1?Q?Radek_Hol=FD?=) Date: Mon, 18 Jun 2012 09:12:17 +0200 Subject: [python-win32] How to find corresponding WMI/COM object for given Windows Registry key? In-Reply-To: <4FDEB494.10406@timgolden.me.uk> References: <4FDE5012.8090801@timgolden.me.uk> <4FDEB494.10406@timgolden.me.uk> Message-ID: 2012/6/18 Tim Golden : > On 18/06/2012 00:58, Radek Hol? wrote: >> >> My question is probably poorly formulated. >> In fact -- as I discovered -- some WMI objects reflect their values in >> the Windows Registry keys (for example there is mapping >> ?root\cimv2:Win32_OSRecoveryConfiguration.AutoReboot? in >> >> ?HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl\AutoReboot?). >> Is there some *common* attribute of WMI/COM/OLE objects giving the key >> path? > > > I don't believe so. The thing about WMI is that it provides a > uniform and accessible layer on top of quite a lot of lower-level > APIs. In some cases, that's a layer over registry entries; in other > cases it's a layer over an actual API call. It may even be the only > publicly-accessible means of achieving some result. > > As it happens, for *methods* there is sometimes a clue as to the > underlying API. I have exposed this as (for want of a better name) the > provenance attribute of a method class. So if you do this: > > > import wmi > > print wmi.WMI().Win32_Process.Create.provenance > > > > You'll see something like this: > > Win32API|Process and Thread Functions|CreateProcess > > I'm not aware of any such thing for attributes, although it wouldn't > surprise me utterly if there were. I know that the dependence WMI <-> WinReg is not frequent. Saying ?common attribute? I thought common to this (reflecting) type of objects. So it seems that it was an exception that I managed to print this thing. Or is it possible that the attribute belongs to underlaying COM or OLE object? (In the pywin32 implementation!) I wonder which object it was... :-/ What a pity that interactive shell does not remember the history of commands after rebooting the computer? :-D -- Radek Hol? Czech republic From sv1jsb at gmail.com Mon Jun 18 21:35:32 2012 From: sv1jsb at gmail.com (=?ISO-8859-7?B?we3k8d3h8iDQ7/Hl9fzw7/Xr7/I=?=) Date: Mon, 18 Jun 2012 22:35:32 +0300 Subject: [python-win32] Connecting to a running COM server Message-ID: Hello, I am new to windows programming and I am trying to connect to a local erp application server which has a registered com interface and provides methods for an external program to communicate with it. With Delphi one can do following and have access to the erp: ... user ComObj ... FSoftOne := CreateOleObject('SoXplorer.SoConnection'); ... FSoftOne.Login('user',''pass'); etc... I am trying to do the same with python but with no success. s1 = win32com.client.GetObject(Class='SoXplorer.SoConnection') I get: pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None) s1 = pythoncom.Connect('SoXplorer.SoConnection') I get: pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None) When there is no server running I do: s1 = win32com.client.Dispatch('SoXplorer.SoConnection') this starts the server but this is not an option because the server will be up all the time. What am I doing wrong? Best regards, Andreas -------------- next part -------------- An HTML attachment was scrubbed... URL: From mvcisback at gmail.com Tue Jun 19 20:24:59 2012 From: mvcisback at gmail.com (Marcell Vazquez-Chanlatte) Date: Tue, 19 Jun 2012 11:24:59 -0700 Subject: [python-win32] Python implementations on Windows 8rt Message-ID: Hey, Does anyone here know about python implementations for windows on Arm. I don't know where exactly where to look and this might be the wrong place but I am willing to help test/port it if necessary. Thanks, -Marcell V.C -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris at kateandchris.net Tue Jun 19 20:49:57 2012 From: chris at kateandchris.net (Chris Lambacher) Date: Tue, 19 Jun 2012 14:49:57 -0400 Subject: [python-win32] Python implementations on Windows 8rt In-Reply-To: References: Message-ID: Microsoft has stated that only . NET apps will run on Windows on ARM so you will likely need to use IronPython if you want to use Python on Windows on Arm. -Chris On Tuesday, June 19, 2012, Marcell Vazquez-Chanlatte wrote: > Hey, > Does anyone here know about python implementations for windows on Arm. I > don't know where exactly where to look and this might be the wrong place > but I am willing to help test/port it if necessary. > > Thanks, > -Marcell V.C > -- Christopher Lambacher chris at kateandchris.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From prashantpadaganur at gmail.com Wed Jun 20 07:14:02 2012 From: prashantpadaganur at gmail.com (prashant padaganur) Date: Wed, 20 Jun 2012 10:44:02 +0530 Subject: [python-win32] accessing Win32_Tpm() Message-ID: Hi, I am new to WMI. I have installed WMI for python and pywin32 extensions to be able to use win32 apis from my python scripts. While I can get all the info from other clasees like Win32_Battery, Win32_Processor I am having tough time with Win32_Tpm class. I want to use Win32_Tpm module in python to play around with various tpm features, but all my references to win32_tpm are returning null. Has anybody been able to use the same without any problems. Any help would be appreciated very much. My code is simple: import wmi,sys,os c = wmi.WMI() for tpm in c.Win32_Tpm(): pass if tpm.IsActivated(): print 'Version %s' %(tpm.SpecVersion) print 'Physical presence %s' %(tpm.PhysicalPresenceVersionInfo) -- Cheers, Prashant G.P -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Wed Jun 20 08:04:24 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 20 Jun 2012 16:04:24 +1000 Subject: [python-win32] Connecting to a running COM server In-Reply-To: References: Message-ID: <4FE167E8.9040506@gmail.com> On 19/06/2012 5:35 AM, ??????? ???????????? wrote: > Hello, > I am new to windows programming and I am trying to connect to a local erp > application server which has a registered com interface and provides > methods for an external program to communicate with it. > With Delphi one can do following and have access to the erp: > ... > user ComObj > ... > > FSoftOne := CreateOleObject('SoXplorer.SoConnection'); > ... > FSoftOne.Login('user',''pass'); > etc... > > I am trying to do the same with python but with no success. > s1 = win32com.client.GetObject(Class='SoXplorer.SoConnection') > I get: > pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None) > > s1 = pythoncom.Connect('SoXplorer.SoConnection') > I get: > pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None) > > When there is no server running I do: > s1 = win32com.client.Dispatch('SoXplorer.SoConnection') > this starts the server but this is not an option because the server will > be up all the time. What happens here is the server is already running? Apart from that, I'm afraid I have no other ideas other than to talk to the provider of the object (or their support forums etc) Cheers, Mark > > What am I doing wrong? > > Best regards, > Andreas > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mail at timgolden.me.uk Wed Jun 20 10:12:30 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 20 Jun 2012 09:12:30 +0100 Subject: [python-win32] accessing Win32_Tpm() In-Reply-To: References: Message-ID: <4FE185EE.9040804@timgolden.me.uk> On 20/06/2012 06:14, prashant padaganur wrote: > Hi, > > I am new to WMI. > > I have installed WMI for python and pywin32 extensions to be able to use > win32 apis from my python scripts. While I can get all the info from > other clasees like Win32_Battery, Win32_Processor I am having tough time > with Win32_Tpm class. > > I want to use Win32_Tpm module in python to play around with various tpm > features, but all my references to win32_tpm are returning null. What do you get if you do? import wmi print wmi.WMI ().Win32_Tpm On my Win7 machine, it's not even present. I know nothing about the technology it's proxying so it may well be that the underlying stuff isn't there to be represented. TJG From prashantpadaganur at gmail.com Wed Jun 20 14:01:12 2012 From: prashantpadaganur at gmail.com (prashant padaganur) Date: Wed, 20 Jun 2012 17:31:12 +0530 Subject: [python-win32] accessing Win32_Tpm() Message-ID: >> Hi, >> >> I am new to WMI. >> >> I have installed WMI for python and pywin32 extensions to be able to use >> win32 apis from my python scripts. While I can get all the info from >> other clasees like Win32_Battery, Win32_Processor I am having tough time >> with Win32_Tpm class. >> >> I want to use Win32_Tpm module in python to play around with various tpm >> features, but all my references to win32_tpm are returning null. >What do you get if you do? > > >import wmi >print wmi.WMI ().Win32_Tpm > > > >On my Win7 machine, it's not even present. I know nothing about the >technology it's proxying so it may well be that the underlying >stuff isn't there to be represented. > >TJG Thanks to your tutorial on WMI I had tried this yesterday. I get the following error when I try printing wmi.WMI ().Win32_Tpm. --------- Traceback (most recent call last): File "C:/Users/ppadagax/Documents/Scripts/freshTpm.py", line 14, in print wmi.WMI ().Win32_Tpm File "C:\Python27\lib\site-packages\wmi.py", line 1147, in __getattr__ return getattr (self._namespace, attribute) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 516, in __getattr__ raise AttributeError("%s.%s" % (self._username_, attr)) AttributeError: winmgmts:.Win32_Tpm ---------- More info about Win32_Tpm class here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa376484(v=vs.85).aspx I have this Tpm chip in my machine which runs on Windows 7 and when I run tpm.msc from the windows run tab, I get all the info from GUI. I need to access the same information programatically through python. I saw few code samples on the internet which implement the same using VB or C#. What I essentially need is the python version of this link which shows how to access Win32_Tpm info using .Net. http://blogs.msdn.com/b/securitytools/archive/2009/07/29/wmi-programming-using-c-net.aspx Br Prashant Padaganur -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Jun 20 14:18:12 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 20 Jun 2012 13:18:12 +0100 Subject: [python-win32] accessing Win32_Tpm() In-Reply-To: References: Message-ID: <4FE1BF84.4010301@timgolden.me.uk> On 20/06/2012 13:01, prashant padaganur wrote: > Thanks to your tutorial on WMI I had tried this yesterday. I get the > following error when I try printing wmi.WMI ().Win32_Tpm. > --------- > Traceback (most recent call last): > File "C:/Users/ppadagax/Documents/Scripts/freshTpm.py", line 14, in > > print wmi.WMI ().Win32_Tpm > File "C:\Python27\lib\site-packages\wmi.py", line 1147, in __getattr__ > return getattr (self._namespace, attribute) > File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line > 516, in __getattr__ > raise AttributeError("%s.%s" % (self._username_, attr)) > AttributeError: winmgmts:.Win32_Tpm > ---------- > > More info about Win32_Tpm class > here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa376484(v=vs.85).aspx > > I have this Tpm chip in my machine which runs on Windows 7 and when I > run tpm.msc from the windows run tab, I get all the info from GUI. I > need to access the same information programatically through python. I > saw few code samples on the internet which implement the same using VB > or C#. What I essentially need is the python version of this link which > shows how to access Win32_Tpm info using .Net. > > http://blogs.msdn.com/b/securitytools/archive/2009/07/29/wmi-programming-using-c-net.aspx According to: http://msdn.microsoft.com/en-us/library/windows/desktop/aa376484%28v=vs.85%29.aspx the Win32_Tpm class is in its own namespace. So try this: import wmi c = wmi.WMI(namespace="root/cimv2/security/microsofttpm") for whatever in c.Win32_Tpm(): # do whatever TJG From prashantpadaganur at gmail.com Wed Jun 20 15:45:09 2012 From: prashantpadaganur at gmail.com (prashant padaganur) Date: Wed, 20 Jun 2012 19:15:09 +0530 Subject: [python-win32] accessing Win32_Tpm() Message-ID: >>* More info about Win32_Tpm class*>>* here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa376484(v=vs.85).aspx*>>* *>>* I have this Tpm chip in my machine which runs on Windows 7 and when I*>>* run tpm.msc from the windows run tab, I get all the info from GUI. I*>>* need to access the same information programatically through python. I*>>* saw few code samples on the internet which implement the same using VB*>>* or C#. What I essentially need is the python version of this link which*>>* shows how to access Win32_Tpm info using .Net.*>>* *>>* http://blogs.msdn.com/b/securitytools/archive/2009/07/29/wmi-programming-using-c-net.aspx* >According to: > >http://msdn.microsoft.com/en-us/library/windows/desktop/aa376484%28v=vs.85%29.aspx > >the Win32_Tpm class is in its own namespace. So try this: > > >import wmi > >c = wmi.WMI(namespace="root/cimv2/security/microsofttpm") >for whatever in c.Win32_Tpm(): > # do whatever > > > >TJG Thanks Tim, it worked. You put and end to my one and half day efforts :-). Between ho can I reply to thread on this mailing list. I don't see any option for that. Cheers, Prashant Padaganur -------------- next part -------------- An HTML attachment was scrubbed... URL: From mmanfre at gmail.com Wed Jun 20 16:50:17 2012 From: mmanfre at gmail.com (Michael Manfre) Date: Wed, 20 Jun 2012 10:50:17 -0400 Subject: [python-win32] Getting output parameters from stored procedures Message-ID: I'm the maintainer of django-mssql and I've run in to an odd behavior when trying to retrieve a stored procedure's output parameters. The parameters (including return value) appear to only get fetched when the last recordset for the stored procedure is loaded. This last recordset appears as if the underlying layer is doing a select, and adding this extra recordset, for the parameters. The observed behavior is equivalent to this bit of SQL. DECLARE @retval int, @someOut int > exec @retval = uspReturnsAResultSetOrTwo @someOut OUTPUT > SELECT @retval, @someOut > I haven't been able to find any documentation stating that this is the intended behavior and this doesn't match my experience of using stored procedures with ADO.NET. Is this expected behavior? Is there some combination of cursor types or attributes to get the output parameter values without fetching/skipping all the recordsets? Regards, Michael Manfre -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Wed Jun 20 17:43:25 2012 From: vernondcole at gmail.com (Vernon Cole) Date: Wed, 20 Jun 2012 09:43:25 -0600 Subject: [python-win32] Getting output parameters from stored procedures In-Reply-To: References: Message-ID: Michael: Last time I looked at the code of django-mssql it was using a fork of adodbapi, not the code I maintain, which is included with pywin32. Nevertheless, I don't think there are any changes in the return parameter handling between the two forks. I just ran across a related page on the AS/400 Python site (of all places) which led me to thinking that I don't really understand how return parameters are supposed to work. I have just blindly kept the code that Ekelund wrote. The test in adodbapi is probably too simple to pick up any edge cases, and the AS/400 version is interesting enough to make me say "Huh?" I think I'll run a version of your question into the python database group, and see what they say. It's definitely weird and should either be made more obvious or documented, or both. Let's keep this discussion running. -- Vernon On Wed, Jun 20, 2012 at 8:50 AM, Michael Manfre wrote: > I'm the maintainer of django-mssql and I've run in to an odd behavior when > trying to retrieve a stored procedure's output parameters. The parameters > (including return value) appear to only get fetched when the last recordset > for the stored procedure is loaded. This last recordset appears as if the > underlying layer is doing a select, and adding this extra recordset, for > the parameters. > > The observed behavior is equivalent to this bit of SQL. > > DECLARE @retval int, @someOut int >> exec @retval = uspReturnsAResultSetOrTwo @someOut OUTPUT >> SELECT @retval, @someOut >> > > I haven't been able to find any documentation stating that this is the > intended behavior and this doesn't match my experience of using stored > procedures with ADO.NET. Is this expected behavior? Is there some > combination of cursor types or attributes to get the output parameter > values without fetching/skipping all the recordsets? > > Regards, > Michael Manfre > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jun 20 18:37:02 2012 From: timr at probo.com (Tim Roberts) Date: Wed, 20 Jun 2012 09:37:02 -0700 Subject: [python-win32] Python implementations on Windows 8rt In-Reply-To: References: Message-ID: <4FE1FC2E.1030608@probo.com> Chris Lambacher wrote: > Microsoft has stated that only . NET apps will run on Windows on ARM > so you will likely need to use IronPython if you want to use Python on > Windows on Arm. That's not correct. The .NET Framework will NOT be ported on Windows ARM, so .NET applications will not run. Only Metro applications (using WinRT) will work on Windows ARM. You will not be using Python on Windows ARM, nor will you be able to distribute Python applications. Windows RT (which is what they're calling the version of Windows 8 that runs on ARM) is to Windows 8 what Android is to Linux. It's a very restricted, tightly controlled environment. It's Windows for Phones, not just another port of Windows desktop. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Matt.funke at vishaypg.com Thu Jun 21 22:25:25 2012 From: Matt.funke at vishaypg.com (Funke, Matt) Date: Thu, 21 Jun 2012 20:25:25 +0000 Subject: [python-win32] How to invoke Python program from Windows service? Message-ID: <2C5C90D76B65DC47A65001FD937014B22D4871B5@WSWD43.vishaypg.com> I'm relatively new to the world of Windows programming, but I have a Python program I'd like to run every once in a while from a Windows service. I've gotten the service itself to run as it's supposed to, but attempts to run the program with a DOS command (using ProcessStartInfo) are unsuccessful. Does anyone have any advice? (This program, written in Python 2.7.3, depends heavily on other libraries - reportlab, SQLAlchemy, and a bunch of others. It works now, and I'd rather not rewrite it if I don't have to.) Matt Funke Programmer/Analyst Vishay Precision Group, Inc. 951 Wendell Blvd Wendell, NC 27591 USA Office: 919-374-5553 Mobile: 919-628-9261 Fax: 919-374-5248 -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Fri Jun 22 03:41:08 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 22 Jun 2012 11:41:08 +1000 Subject: [python-win32] How to invoke Python program from Windows service? In-Reply-To: <2C5C90D76B65DC47A65001FD937014B22D4871B5@WSWD43.vishaypg.com> References: <2C5C90D76B65DC47A65001FD937014B22D4871B5@WSWD43.vishaypg.com> Message-ID: <4FE3CD34.2000207@gmail.com> On 22/06/2012 6:25 AM, Funke, Matt wrote: > I?m relatively new to the world of Windows programming, but I have a > Python program I?d like to run every once in a while from a Windows > service. I?ve gotten the service itself to run as it?s supposed to, but > attempts to run the program with a DOS command (using ProcessStartInfo) > are unsuccessful. Does anyone have any advice? Note you can write the service directly in Python using pywin32. If you want to write the service using some other technology and just spawn Python, then I'd suggest using just CreateProcess. But with both CreateProcess and ProcessStartInfo, you need a way to redirect output from the Python process so you can get diagnostics from the output - just telling us it is "unsuccessful" doesn't help us tell you what problem you have. Mark > > (This program, written in Python 2.7.3, depends heavily on other > libraries ? reportlab, SQLAlchemy, and a bunch of others. It works now, > and I?d rather not rewrite it if I don?t have to.) > > *Matt Funke*** > > Programmer/Analyst > > Vishay Precision Group, Inc. > > 951 Wendell Blvd > > Wendell, NC 27591 USA > > Office: 919-374-5553 > > Mobile: 919-628-9261 > > Fax: 919-374-5248 > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From ferdinandsousa at gmail.com Fri Jun 22 08:10:56 2012 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Fri, 22 Jun 2012 11:40:56 +0530 Subject: [python-win32] Installing pywin32 for Python 2.7 AMD64 In-Reply-To: <4FDEAAAB.6090900@gmail.com> References: <4FDEAAAB.6090900@gmail.com> Message-ID: Hi Mark, I'm guessing User Access Control is not disabled for me. I have an administrator account on Win 7 Professional. While installing stuff, very often at the last step of the install wizard, I get the install button with the chequered shield symbol, indicating admin credentials required. Since my account is an admin, I get a modal dialog asking whether I want to continue or not. This did NOT happen for the pywin32 installer mentioned below. However since you made the suggestion I explicitly chose to run the installer as admin and it works fine now (I am able to import win32api, win32gui etc), even though I still get the same error at the finish stage of the install wizard mentioned earlier: ---------------------------------------------------------------------------------------------- Postinstall script finished Click the Finish button to exit the setup wizard close failed in file object destructor: sys.excepthook is missing lost sys.stderr ---------------------------------------------------------------------------------------------- Thanks for the tip. Best regards, Ferdi On Mon, Jun 18, 2012 at 9:42 AM, Mark Hammond wrote: > On 16/06/2012 2:20 AM, Ferdinand Sousa wrote: > >> Hi List, >> >> First off, it's good to be back after 3 years!! >> >> I was dusting off some old scripts I had written using pywin32. (Python >> 2.5 era I think). It uses the win32con and win32api modules. >> >> Now I'm trying to use the same scripts with Python 2.7 AMD64 version. >> >> I downloaded pywin32-217.win-amd64-py2.7.**exe from the sourceforge site >> and installed it. At the end, I see the following message: >> ------------------------------**------------------------------** >> ------------------------------**---- >> Postinstall script finished >> Click the Finish button to exit the setup wizard >> >> close failed in file object destructor: >> sys.excepthook is missing >> lost sys.stderr >> ------------------------------**------------------------------** >> ------------------------------**---- >> > > This seems to happen if User Access Control (UAC) is disabled - is it > disabled for you? > > Either way, try running "python scripts\pywin32_postinstall.py -install" > from the root of the install directory and things should finish registering > - that should fix the next error you see. > > > >> Then, I tried importing win32con and it works. But, when I tried >> importing win32api, win32gui I get the error message: >> >> ------------------------------**------------------------------** >> ------------------------------**---- >> Traceback (most recent call last): >> File "", line 1, in >> import win32api, win32gui >> ImportError: DLL load failed: The specified module could not be found. >> ------------------------------**------------------------------** >> ------------------------------**---- >> >> So I uninstalled pywin32 and tried installing it from source. But alas, >> I again hit a roadblock: >> >> ------------------------------**------------------------------** >> ------------------------------**---- >> C:\Users\ferdinand\Downloads\**pywin32-217>c:\Python27\**python.exe >> setup.py >> install >> Building pywin32 2.7.217.0 >> Traceback (most recent call last): >> File "setup.py", line 1944, in >> """ % dirs).split(), >> File "setup.py", line 603, in __init__ >> if os.path.isfile(os.path.join(**sdk_dir, "include", "activdbg.h")): >> File "c:\Python27\lib\ntpath.py", line 96, in join >> assert len(path) > 0 >> TypeError: object of type 'NoneType' has no len() >> > > This will probably be due to the setup script not finding the platform SDK. > > HTH, > > Mark > >> >> C:\Users\ferdinand\Downloads\**pywin32-217> >> ------------------------------**------------------------------** >> ------------------------------**---- >> >> Any pointers? >> >> Thanks in advance, >> Ferdi >> >> >> >> ______________________________**_________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/**mailman/listinfo/python-win32 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Matt.funke at vishaypg.com Fri Jun 22 13:19:21 2012 From: Matt.funke at vishaypg.com (Funke, Matt) Date: Fri, 22 Jun 2012 11:19:21 +0000 Subject: [python-win32] How to invoke Python program from Windows service? In-Reply-To: <4FE3CD34.2000207@gmail.com> References: <2C5C90D76B65DC47A65001FD937014B22D4871B5@WSWD43.vishaypg.com> <4FE3CD34.2000207@gmail.com> Message-ID: <2C5C90D76B65DC47A65001FD937014B22D487325@WSWD43.vishaypg.com> > Note you can write the service directly in Python using pywin32. If > you want to write the service using some other technology and just > spawn Python, then I'd suggest using just CreateProcess. But with > both CreateProcess and ProcessStartInfo, you need a way to > redirect output from the Python process so you can get diagnostics > from the output - just telling us it is "unsuccessful" doesn't help us > tell you what problem you have. Yeah, that was exactly my problem; I had no way to diagnose what was going on, and needed a springboard to tell me what I needed to know in order to figure out what was happening (or not). I could verify that the script *worked*, since I could run it from a DOS prompt without errors. But when I ran it using CreateProcess (and ProcessStartInfo), I didn't see it execute (since it would have created a file in its directory). However, your answer that I can write it directly with pywin32 intrigues me, especially since I'd rather develop in Python anyway. I'll go see what's involved in doing that. Thanks for the pointer! From haraldarminmassa at gmail.com Fri Jun 22 13:39:00 2012 From: haraldarminmassa at gmail.com (Harald Armin Massa[legacy]) Date: Fri, 22 Jun 2012 13:39:00 +0200 Subject: [python-win32] How to invoke Python program from Windows service? In-Reply-To: <2C5C90D76B65DC47A65001FD937014B22D487325@WSWD43.vishaypg.com> References: <2C5C90D76B65DC47A65001FD937014B22D4871B5@WSWD43.vishaypg.com> <4FE3CD34.2000207@gmail.com> <2C5C90D76B65DC47A65001FD937014B22D487325@WSWD43.vishaypg.com> Message-ID: Matt, > > Yeah, that was exactly my problem; I had no way to diagnose what was going on, and >needed a springboard to tell me what I needed to know in order to figure out what was >happening (or not). ?I could verify that the script *worked*, since I could run it from a DOS >prompt without errors. ?But when I ran it using CreateProcess (and ProcessStartInfo), I >didn't see it execute (since it would have created a file in its directory). > > However, your answer that I can write it directly with pywin32 intrigues me, especially since >I'd rather develop in Python anyway. ?I'll go see what's involved in doing that. ?Thanks for the >pointer! >From my experiences with Python windows services some things to lookout for: - the "working directory" of the service is usually where the service control programm resides; especially NOT your Python directory - the path is usually the system path. It is not uncommon that Python resides in a different path - network drives are often not mapped for services, so make sure to use UNC-paths - some windows-system-dlls may have the same name as some of your python-programm files (or, even worse, as some of the Python files of any one of standard library or your used libraries). Windows usually looks first into the current directory ... which may have unexpected results when "import xxxx" loads xxxx.dll from windows, instead of your xxxx.py Best wishes, Harald -- LightningTalkMan a brand of GHUM GmbH Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 From mail at timgolden.me.uk Fri Jun 22 14:17:08 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 22 Jun 2012 13:17:08 +0100 Subject: [python-win32] How to invoke Python program from Windows service? In-Reply-To: <2C5C90D76B65DC47A65001FD937014B22D487325@WSWD43.vishaypg.com> References: <2C5C90D76B65DC47A65001FD937014B22D4871B5@WSWD43.vishaypg.com> <4FE3CD34.2000207@gmail.com> <2C5C90D76B65DC47A65001FD937014B22D487325@WSWD43.vishaypg.com> Message-ID: <4FE46244.4050808@timgolden.me.uk> > Yeah, that was exactly my problem; I had no way to diagnose what was > going on, and needed a springboard to tell me what I needed to know > in order to figure out what was happening (or not). I could verify > that the script *worked*, since I could run it from a DOS prompt > without errors. But when I ran it using CreateProcess (and > ProcessStartInfo), I didn't see it execute (since it would have > created a file in its directory). > > However, your answer that I can write it directly with pywin32 > intrigues me, especially since I'd rather develop in Python anyway. > I'll go see what's involved in doing that. Thanks for the pointer! For reference, this is the kind of pattern I use when writing Windows Services in Python: class Engine(object): def __init__(self): self._stop_event = threading.Event() def start(self): # do stuff until self._stop_event is set def stop(self): # set self._stop_event if __name__ == '__main__': Engine().start() import win32event import win32service import win32serviceutil import my_module class Service (win32serviceutil.ServiceFramework): _svc_name_ = "MyService" _svc_display_name_ = "A Service of Mine" def __init__ (self, args): win32serviceutil.ServiceFramework.__init__ (self, args) self.stop_event = win32event.CreateEvent (None, 0, 0, None) self.engine = my_module.Engine () def SvcDoRun (self): self.engine.start (True) win32event.WaitForSingleObject (self.stop_event, win32event.INFINITE) def SvcStop (self): self.ReportServiceStatus (win32service.SERVICE_STOP_PENDING) self.engine.stop () win32event.SetEvent (self.stop_event) if __name__ == '__main__': win32serviceutil.HandleCommandLine (Service) To install the service you run the my_service.py module with the parameter "install". (The reverse is done by passing "remove"). HTH TJG From mhammond at skippinet.com.au Fri Jun 22 14:57:53 2012 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 22 Jun 2012 22:57:53 +1000 Subject: [python-win32] How to invoke Python program from Windows service? In-Reply-To: <2C5C90D76B65DC47A65001FD937014B22D487325@WSWD43.vishaypg.com> References: <2C5C90D76B65DC47A65001FD937014B22D4871B5@WSWD43.vishaypg.com> <4FE3CD34.2000207@gmail.com> <2C5C90D76B65DC47A65001FD937014B22D487325@WSWD43.vishaypg.com> Message-ID: <4FE46BD1.6030007@skippinet.com.au> Services are pretty tricky - you might be better off arranging for the Python script to write sys.stderr somewhere useful and seeing what the traceback says - you'll almost certainly strike the same problem after you get a pywin32 based one close to working. Mark On 22/06/2012 9:19 PM, Funke, Matt wrote: >> Note you can write the service directly in Python using pywin32. If >> you want to write the service using some other technology and just >> spawn Python, then I'd suggest using just CreateProcess. But with >> both CreateProcess and ProcessStartInfo, you need a way to >> redirect output from the Python process so you can get diagnostics >> from the output - just telling us it is "unsuccessful" doesn't help us >> tell you what problem you have. > > Yeah, that was exactly my problem; I had no way to diagnose what was going on, and needed a springboard to tell me what I needed to know in order to figure out what was happening (or not). I could verify that the script *worked*, since I could run it from a DOS prompt without errors. But when I ran it using CreateProcess (and ProcessStartInfo), I didn't see it execute (since it would have created a file in its directory). > > However, your answer that I can write it directly with pywin32 intrigues me, especially since I'd rather develop in Python anyway. I'll go see what's involved in doing that. Thanks for the pointer! > From Matt.funke at vishaypg.com Fri Jun 22 14:59:35 2012 From: Matt.funke at vishaypg.com (Funke, Matt) Date: Fri, 22 Jun 2012 12:59:35 +0000 Subject: [python-win32] How to invoke Python program from Windows service? In-Reply-To: References: <2C5C90D76B65DC47A65001FD937014B22D4871B5@WSWD43.vishaypg.com> <4FE3CD34.2000207@gmail.com> <2C5C90D76B65DC47A65001FD937014B22D487325@WSWD43.vishaypg.com> Message-ID: <2C5C90D76B65DC47A65001FD937014B22D4873DD@WSWD43.vishaypg.com> > From my experiences with Python windows services some things to lookout for: > > - the "working directory" of the service is usually where the service control > programm resides; especially NOT your Python directory > > - the path is usually the system path. It is not uncommon that Python resides > in a different path > > - network drives are often not mapped for services, so make sure to use > UNC-paths > > - some windows-system-dlls may have the same name as some of your > python-programm files (or, even worse, as some of the Python files of any > one of standard library or your used libraries). Windows usually looks first > into the current directory ... which may have unexpected results when > "import xxxx" loads xxxx.dll from windows, instead of your xxxx.py Thanks for the heads-up. If I run into some "unexpected results", I'll be sure to try these things first. From matteo.boscolo at boscolini.eu Fri Jun 22 15:13:01 2012 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Fri, 22 Jun 2012 15:13:01 +0200 Subject: [python-win32] How to create a empty com object In-Reply-To: <4D619485.609@skippinet.com.au> References: <4D5F08D0.3010903@skippinet.com.au> <4D617CC5.4050509@boscolini.eu> <4D619485.609@skippinet.com.au> Message-ID: <4FE46F5D.9050500@boscolini.eu> Hi all , Today I weak up and just came back to my code .. I finally got a good solution for this problem :)))) and here it is ... ......activeComponent=VARIANT(pythoncom.VT_VARIANT | pythoncom.VT_NULL,None) regards, Matteo Il 20/02/2011 23:24, Mark Hammond ha scritto: > On 21/02/2011 7:42 AM, Matteo Boscolo wrote: >> >> I did some other search I try to pass a object() to the activeComponent >> but the active component need a COM VARIANT.. >> >> there is any way to create a null COM VARIANT ? >> or to pass a c++ NULL equivalent object ? > > win32com automatically creates a variant - if you pass None, it will > create a variant with VT_NULL, and if you pass pythoncom.Empty, it > will pass a variant with VT_EMPTY. If Empty also doesn't work, I'm > afraid I'm out of ideas... > > Cheers, > > Mark. > > > > ----- > Nessun virus nel messaggio. > Controllato da AVG - www.avg.com > Versione: 10.0.1204 / Database dei virus: 1435/3455 - Data di > rilascio: 20/02/2011 > > From matteo.boscolo at boscolini.eu Fri Jun 22 15:13:52 2012 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Fri, 22 Jun 2012 15:13:52 +0200 Subject: [python-win32] How to create a empty com object In-Reply-To: <4D619485.609@skippinet.com.au> References: <4D5F08D0.3010903@skippinet.com.au> <4D617CC5.4050509@boscolini.eu> <4D619485.609@skippinet.com.au> Message-ID: <4FE46F90.3030806@boscolini.eu> Hi all , Today I weak up and just came back to my code .. I finally got a good solution for this problem :)))) and here it is ... ......activeComponent=VARIANT(pythoncom.VT_VARIANT | pythoncom.VT_NULL,None) regards, Matteo Il 20/02/2011 23:24, Mark Hammond ha scritto: > On 21/02/2011 7:42 AM, Matteo Boscolo wrote: >> >> I did some other search I try to pass a object() to the activeComponent >> but the active component need a COM VARIANT.. >> >> there is any way to create a null COM VARIANT ? >> or to pass a c++ NULL equivalent object ? > > win32com automatically creates a variant - if you pass None, it will > create a variant with VT_NULL, and if you pass pythoncom.Empty, it > will pass a variant with VT_EMPTY. If Empty also doesn't work, I'm > afraid I'm out of ideas... > > Cheers, > > Mark. > > > > ----- > Nessun virus nel messaggio. > Controllato da AVG - www.avg.com > Versione: 10.0.1204 / Database dei virus: 1435/3455 - Data di > rilascio: 20/02/2011 > > From Matt.funke at vishaypg.com Fri Jun 22 15:00:27 2012 From: Matt.funke at vishaypg.com (Funke, Matt) Date: Fri, 22 Jun 2012 13:00:27 +0000 Subject: [python-win32] How to invoke Python program from Windows service? In-Reply-To: <4FE46244.4050808@timgolden.me.uk> References: <2C5C90D76B65DC47A65001FD937014B22D4871B5@WSWD43.vishaypg.com> <4FE3CD34.2000207@gmail.com> <2C5C90D76B65DC47A65001FD937014B22D487325@WSWD43.vishaypg.com> <4FE46244.4050808@timgolden.me.uk> Message-ID: <2C5C90D76B65DC47A65001FD937014B22D4873E9@WSWD43.vishaypg.com> > For reference, this is the kind of pattern I use when writing Windows Services in Python: This is incredibly useful. Thank you. Matt Funke Programmer/Analyst Vishay Precision Group, Inc. 951 Wendell Blvd Wendell, NC 27591 USA Office: 919-374-5553 Mobile: 919-628-9261 Fax: 919-374-5248 From python at bdurham.com Fri Jun 22 15:59:08 2012 From: python at bdurham.com (python at bdurham.com) Date: Fri, 22 Jun 2012 09:59:08 -0400 Subject: [python-win32] =?iso-8859-1?q?How_to_invoke_Python_program_from?= =?iso-8859-1?q?=09Windows=09service=3F?= In-Reply-To: <2C5C90D76B65DC47A65001FD937014B22D4873E9@WSWD43.vishaypg.com> References: <2C5C90D76B65DC47A65001FD937014B22D4871B5@WSWD43.vishaypg.com> <4FE3CD34.2000207@gmail.com> <2C5C90D76B65DC47A65001FD937014B22D487325@WSWD43.vishaypg.com> <4FE46244.4050808@timgolden.me.uk> <2C5C90D76B65DC47A65001FD937014B22D4873E9@WSWD43.vishaypg.com> Message-ID: <1340373548.730.140661092655301.0C339B19@webmail.messagingengine.com> >> For reference, this is the kind of pattern I use when writing Windows Services in Python: > This is incredibly useful. Thank you. +1 Malcolm From chris at kateandchris.net Sat Jun 23 03:32:41 2012 From: chris at kateandchris.net (Chris Lambacher) Date: Fri, 22 Jun 2012 21:32:41 -0400 Subject: [python-win32] Python implementations on Windows 8rt In-Reply-To: <4FE1FC2E.1030608@probo.com> References: <4FE1FC2E.1030608@probo.com> Message-ID: On Wed, Jun 20, 2012 at 12:37 PM, Tim Roberts wrote: > Chris Lambacher wrote: > > Microsoft has stated that only . NET apps will run on Windows on ARM > > so you will likely need to use IronPython if you want to use Python on > > Windows on Arm. > > That's not correct. The .NET Framework will NOT be ported on Windows > ARM, so .NET applications will not run. Only Metro applications (using > WinRT) will work on Windows ARM. You will not be using Python on > Windows ARM, nor will you be able to distribute Python applications. > Metro apps can be written in so called managed (i.e. .net code) (see: http://blogs.microsoft.co.il/blogs/sasha/archive/2011/09/15/winrt-and-net-in-windows-8.aspx and http://channel9.msdn.com/Events/BUILD/BUILD2011/TOOL-531T ) so theoretically IronPython would be embeddable in an app targeting Metro and could be made to run on Windows RT (the O.S. Formerly know as Windows on ARM). Here is an IronPython mailing list thread on just that: http://mail.python.org/pipermail//ironpython-users/2011-November/015409.html Further investigation also shows that (at least on x86) it might be possible to have a version of Python for Metro Apps that is based on CPython: http://mail.python.org/pipermail/python-dev/2012-January/115426.html > Windows RT (which is what they're calling the version of Windows 8 that > runs on ARM) is to Windows 8 what Android is to Linux. It's a very > restricted, tightly controlled environment. It's Windows for Phones, > not just another port of Windows desktop. > Just to be clear I referred to Windows RT the OS as Windows on ARM to be less confusing with Windows Runtime the programming API for Metro Style Apps. -Chris -- Christopher Lambacher chris at kateandchris.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris at kateandchris.net Sat Jun 23 05:38:42 2012 From: chris at kateandchris.net (Chris Lambacher) Date: Fri, 22 Jun 2012 23:38:42 -0400 Subject: [python-win32] Getting output parameters from stored procedures In-Reply-To: References: Message-ID: On Wed, Jun 20, 2012 at 10:50 AM, Michael Manfre wrote: > The observed behavior is equivalent to this bit of SQL. > > DECLARE @retval int, @someOut int >> exec @retval = uspReturnsAResultSetOrTwo @someOut OUTPUT >> SELECT @retval, @someOut >> > > I haven't been able to find any documentation stating that this is the > intended behavior and this doesn't match my experience of using stored > procedures with ADO.NET. Is this expected behavior? Is there some > combination of cursor types or attributes to get the output parameter > values without fetching/skipping all the recordsets? > This is the behaviour of the Microsoft's ADO library which is the underlying api that adodbapi works against. It is pretty hard to find docs for ADO because ADO.NET sucks up all the hits and Microsoft's own MSDN docs for ADO are pretty weak. Also, that is fundamentally the pattern you would use with ODBC too which does not have any particular notion of Stored Proceedures. ADO is based on ODBC connections so that may be the source of this particular behind the scenes idiom. -Chris -- Christopher Lambacher chris at kateandchris.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From mmanfre at gmail.com Sat Jun 23 06:01:12 2012 From: mmanfre at gmail.com (Michael Manfre) Date: Sat, 23 Jun 2012 00:01:12 -0400 Subject: [python-win32] Getting output parameters from stored procedures In-Reply-To: References: Message-ID: I was approaching the conclusion that this is expected behavior. Glad to have it confirmed with a reasonable explanation why. I guess the fix will be to document the behavior. Thanks, Michael Manfre On Fri, Jun 22, 2012 at 11:38 PM, Chris Lambacher wrote: > > > On Wed, Jun 20, 2012 at 10:50 AM, Michael Manfre wrote: > >> The observed behavior is equivalent to this bit of SQL. >> >> DECLARE @retval int, @someOut int >>> exec @retval = uspReturnsAResultSetOrTwo @someOut OUTPUT >>> SELECT @retval, @someOut >>> >> >> I haven't been able to find any documentation stating that this is the >> intended behavior and this doesn't match my experience of using stored >> procedures with ADO.NET. Is this expected behavior? Is there some >> combination of cursor types or attributes to get the output parameter >> values without fetching/skipping all the recordsets? >> > > This is the behaviour of the Microsoft's ADO library which is the > underlying api that adodbapi works against. It is pretty hard to find docs > for ADO because ADO.NET sucks up all the hits and Microsoft's own MSDN > docs for ADO are pretty weak. Also, that is fundamentally the pattern you > would use with ODBC too which does not have any particular notion of Stored > Proceedures. ADO is based on ODBC connections so that may be the source of > this particular behind the scenes idiom. > > -Chris > > -- > Christopher Lambacher > chris at kateandchris.net > -------------- next part -------------- An HTML attachment was scrubbed... URL: From radekholypublic at gmail.com Sat Jun 23 15:03:01 2012 From: radekholypublic at gmail.com (=?ISO-8859-1?Q?Radek_Hol=FD?=) Date: Sat, 23 Jun 2012 15:03:01 +0200 Subject: [python-win32] How to find corresponding WMI/COM object for given Windows Registry key? In-Reply-To: References: <4FDE5012.8090801@timgolden.me.uk> <4FDEB494.10406@timgolden.me.uk> Message-ID: 2012/6/18 Radek Hol? : > 2012/6/18 Tim Golden : >> On 18/06/2012 00:58, Radek Hol? wrote: >>> >>> My question is probably poorly formulated. >>> In fact -- as I discovered -- some WMI objects reflect their values in >>> the Windows Registry keys (for example there is mapping >>> ?root\cimv2:Win32_OSRecoveryConfiguration.AutoReboot? in >>> >>> ?HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl\AutoReboot?). >>> Is there some *common* attribute of WMI/COM/OLE objects giving the key >>> path? >> >> >> I don't believe so. The thing about WMI is that it provides a >> uniform and accessible layer on top of quite a lot of lower-level >> APIs. In some cases, that's a layer over registry entries; in other >> cases it's a layer over an actual API call. It may even be the only >> publicly-accessible means of achieving some result. >> >> As it happens, for *methods* there is sometimes a clue as to the >> underlying API. I have exposed this as (for want of a better name) the >> provenance attribute of a method class. So if you do this: >> >> >> import wmi >> >> print wmi.WMI().Win32_Process.Create.provenance >> >> >> >> You'll see something like this: >> >> Win32API|Process and Thread Functions|CreateProcess >> >> I'm not aware of any such thing for attributes, although it wouldn't >> surprise me utterly if there were. > > I know that the dependence WMI <-> WinReg is not frequent. Saying > ?common attribute? I thought common to this (reflecting) type of > objects. So it seems that it was an exception that I managed to print > this thing. > Or is it possible that the attribute belongs to underlaying COM or OLE > object? (In the pywin32 implementation!) > > I wonder which object it was... :-/ What a pity that interactive shell > does not remember the history of commands after rebooting the > computer? :-D > -- > Radek Hol? > Czech republic Hello, I was advised to look at the ``MappingStrings`` qualifier. So far it seems that the only way is to list ``MappingStrings`` qualifiers of all properties. Something like this: >>> import wmi >>> import pywintypes >>> >>> def walk_namespace(namespace_path): ... namespace = wmi.WMI(computer=".", namespace=namespace_path, find_classes=True) ... ... subclasses_names = namespace.classes ... for subclass_name in subclasses_names: ... subclass = getattr(namespace, subclass_name) ... ... subclass_path = str(subclass.path()) ... subclass_mapping = get_mapping(subclass) ... save_mapping(subclass_path, subclass_mapping) ... ... for property in subclass.Properties_: ... property_path = ".".join((subclass_path, property.Name)) ... property_mapping = get_mapping(property) ... save_mapping(property_path, property_mapping) ... ... subnamespaces = namespace.__Namespace() ... for subnamespace in subnamespaces: ... subnamespace_path = "/".join((namespace_path, subnamespace.Name)) ... walk_namespace(subnamespace_path) ... >>> def get_mapping(object_): ... try: ... mapping = object_.Qualifiers_("MappingStrings") ... except pywintypes.com_error as err: ... if err.excepinfo[5] == -2147217406: ... return () ... else: ... raise ... else: ... return mapping.Value ... >>> def save_mapping(path, mapping): ... if mapping: ... print(path, mapping) ... >>> walk_namespace("root") I hope that this code passes through all the classes and their properties. And in this case, I hope that this code prints all available "dependencies". -- Radek Hol? Czech republic From mail at timgolden.me.uk Sat Jun 23 17:17:39 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 23 Jun 2012 16:17:39 +0100 Subject: [python-win32] How to find corresponding WMI/COM object for given Windows Registry key? In-Reply-To: References: <4FDE5012.8090801@timgolden.me.uk> <4FDEB494.10406@timgolden.me.uk> Message-ID: <4FE5DE13.20205@timgolden.me.uk> On 23/06/2012 14:03, Radek Hol? wrote: > 2012/6/18 Radek Hol? : >> 2012/6/18 Tim Golden : >>> On 18/06/2012 00:58, Radek Hol? wrote: >>>> >>>> My question is probably poorly formulated. >>>> In fact -- as I discovered -- some WMI objects reflect their values in >>>> the Windows Registry keys (for example there is mapping >>>> ?root\cimv2:Win32_OSRecoveryConfiguration.AutoReboot? in >>>> >>>> ?HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl\AutoReboot?). >>>> Is there some *common* attribute of WMI/COM/OLE objects giving the key >>>> path? >>> >>> >>> I don't believe so. The thing about WMI is that it provides a >>> uniform and accessible layer on top of quite a lot of lower-level >>> APIs. In some cases, that's a layer over registry entries; in other >>> cases it's a layer over an actual API call. It may even be the only >>> publicly-accessible means of achieving some result. >>> >>> As it happens, for *methods* there is sometimes a clue as to the >>> underlying API. I have exposed this as (for want of a better name) the >>> provenance attribute of a method class. So if you do this: >>> >>> >>> import wmi >>> >>> print wmi.WMI().Win32_Process.Create.provenance >>> >>> >>> >>> You'll see something like this: >>> >>> Win32API|Process and Thread Functions|CreateProcess >>> >>> I'm not aware of any such thing for attributes, although it wouldn't >>> surprise me utterly if there were. >> >> I know that the dependence WMI <-> WinReg is not frequent. Saying >> ?common attribute? I thought common to this (reflecting) type of >> objects. So it seems that it was an exception that I managed to print >> this thing. >> Or is it possible that the attribute belongs to underlaying COM or OLE >> object? (In the pywin32 implementation!) >> >> I wonder which object it was... :-/ What a pity that interactive shell >> does not remember the history of commands after rebooting the >> computer? :-D >> -- >> Radek Hol? >> Czech republic > > > Hello, > > I was advised to look at the ``MappingStrings`` qualifier. So far it > seems that the only way is to list ``MappingStrings`` qualifiers of > all properties. [... snip code ...] Thanks for the hint. I'll take a look at that myself with a view to fitting it into the wmi module TJG From mail at timgolden.me.uk Mon Jun 25 10:16:55 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 25 Jun 2012 09:16:55 +0100 Subject: [python-win32] How to find corresponding WMI/COM object for given Windows Registry key? In-Reply-To: References: <4FDE5012.8090801@timgolden.me.uk> <4FDEB494.10406@timgolden.me.uk> Message-ID: <4FE81E77.1000707@timgolden.me.uk> On 23/06/2012 14:03, Radek Hol? wrote: > I was advised to look at the ``MappingStrings`` qualifier. So far it > seems that the only way is to list ``MappingStrings`` qualifiers of > all properties. Ahem. That was embarrassing. It appears that I already knew about the MappingStrings qualifier, because that's the attribute behind the .provenance attribute I already mentioned for methods. For some reason I'd never thought of looking for it on properties. So in the svn trunk I've added it to properties and enhanced the wmiweb app so that, where this is a mapping string, it shows up as a tooltip (visually hinted by a dotted underline). Note to self: do a release at some point soonish. http://svn.timgolden.me.uk/wmi/trunk Thanks for the tip, Radek. TJG From radekholypublic at gmail.com Mon Jun 25 12:21:45 2012 From: radekholypublic at gmail.com (=?ISO-8859-1?Q?Radek_Hol=FD?=) Date: Mon, 25 Jun 2012 12:21:45 +0200 Subject: [python-win32] How to find corresponding WMI/COM object for given Windows Registry key? In-Reply-To: <4FE81E77.1000707@timgolden.me.uk> References: <4FDE5012.8090801@timgolden.me.uk> <4FDEB494.10406@timgolden.me.uk> <4FE81E77.1000707@timgolden.me.uk> Message-ID: 2012/6/25 Tim Golden : > On 23/06/2012 14:03, Radek Hol? wrote: >> I was advised to look at the ``MappingStrings`` qualifier. So far it >> seems that the only way is to list ``MappingStrings`` qualifiers of >> all properties. > > Ahem. That was embarrassing. It appears that I already knew about the > MappingStrings qualifier, because that's the attribute behind the > .provenance attribute I already mentioned for methods. For some reason > I'd never thought of looking for it on properties. > > So in the svn trunk I've added it to properties and enhanced the > wmiweb app so that, where this is a mapping string, it shows up > as a tooltip (visually hinted by a dotted underline). > Note to self: do a release at some point soonish. > > ?http://svn.timgolden.me.uk/wmi/trunk > > Thanks for the tip, Radek. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 Glad to help, even though I only forwarded the method which was recommended to me. -- Radek Hol? Czech republic From crossrocker at gmail.com Mon Jun 25 19:19:25 2012 From: crossrocker at gmail.com (Ryan Hanson) Date: Mon, 25 Jun 2012 12:19:25 -0500 Subject: [python-win32] Trouble With Events in Inventor Message-ID: Hi everyone. I am trying to write a small addin for Autodesk Inventor using COM but I am having trouble getting events to work with my script. I can type my code out in PythonWin and everything works as expected but when I save it out to .py file it just runs though and exits. The same thing seems to happen when I register it on my system as an inventor addin. Here is a small piece of sample code I have been using to try to sort this out. [code] import win32com.client from win32com.client import gencache mod=gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0) oApp=win32com.client.Dispatch("Inventor.Application") oApp.Visible=True oApp_m=mod.Application(oApp) button=oApp_m.CommandManager.ControlDefinitions.AddButtonDefinition("Dxf Update", "dxf", 4) button.AutoAddToGUI() class BEvent(): def OnExecute(self, Context): oPartDoc=oApp_m.Documents.Open("C:\\inventor\\2415 TRUNKING.ipt") win32com.client.DispatchWithEvents(button, BEvent) [/code] All the code works expect for BEvent isn't called when button is pressed. I am not sure where to go from here. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Jun 25 19:56:50 2012 From: timr at probo.com (Tim Roberts) Date: Mon, 25 Jun 2012 10:56:50 -0700 Subject: [python-win32] Python implementations on Windows 8rt In-Reply-To: References: <4FE1FC2E.1030608@probo.com> Message-ID: <4FE8A662.1010502@probo.com> Chris Lambacher wrote: > > Metro apps can be written in so called managed (i.e. .net code)... so > theoretically IronPython would be embeddable in an app targeting Metro > and could be made to run on Windows RT (the O.S. Formerly know as > Windows on ARM). The fact that there is so much confusion about this topic shows what a terribly job Microsoft is doing of marketing all of this. I'm relatively well connected, Microsoft-wise, but you presented several tidbits I had not seen before. > Windows RT (which is what they're calling the version of Windows 8 > that runs on ARM) is to Windows 8 what Android is to Linux. It's > a very restricted, tightly controlled environment. It's Windows > for Phones, not just another port of Windows desktop. > > > Just to be clear I referred to Windows RT the OS as Windows on ARM to > be less confusing with Windows Runtime the programming API for Metro > Style Apps. Yes, me, too. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rupole at hotmail.com Tue Jun 26 04:55:13 2012 From: rupole at hotmail.com (Roger Upole) Date: Mon, 25 Jun 2012 22:55:13 -0400 Subject: [python-win32] Trouble With Events in Inventor References: Message-ID: If you're running the script from python.exe, you'll need to run a message loop (pythoncom.PumpMessages()) to receive events. You don't need that in Pythonwin since it runs its own message loop. Also, are you sure the event class should be attached to the button itself ? I'm not familiar with this application, but normally the top level COM object receives the events. Roger From radekholypublic at gmail.com Wed Jun 27 20:01:26 2012 From: radekholypublic at gmail.com (=?ISO-8859-1?Q?Radek_Hol=FD?=) Date: Wed, 27 Jun 2012 20:01:26 +0200 Subject: [python-win32] Constants for scripting short names of WMI privileges Message-ID: Hello, I would like to ask you whether I can use any combination of pywin32/`wmi`_ constants and functions to get "scripting short names" of WMI privileges [1]_. I found the ``win32security.SE_*_NAME`` constants, but I?m not able to use them to achieve the goal. I would like to use these names in construction of WMI monikers. .. _wmi: http://timgolden.me.uk/python/wmi/ .. [1] See: http://msdn.microsoft.com/en-us/library/aa392758%28VS.85%29.aspx Thank you very much -- Radek Hol? Czech republic From mvcisback at gmail.com Thu Jun 28 19:55:19 2012 From: mvcisback at gmail.com (Marcell Vazquez-Chanlatte) Date: Thu, 28 Jun 2012 10:55:19 -0700 Subject: [python-win32] Python implementations on Windows 8rt In-Reply-To: <4FE8A662.1010502@probo.com> References: <4FE1FC2E.1030608@probo.com> <4FE8A662.1010502@probo.com> Message-ID: So I've been trying to compile the ARM build for internal testing (aka have access to the win32 API) I'm having trouble actually setting up the project to accept the new platform. I'm new to visual studio but does anyone have any suggestions? Getting : fatal error LNK1112: module machine type 'ARM' conflicts with target machine type 'X86' 1> I'm pretty sure there is an error in the config file but I'm not sure. -Marcell V.C On Mon, Jun 25, 2012 at 10:56 AM, Tim Roberts wrote: > Chris Lambacher wrote: > > > > Metro apps can be written in so called managed (i.e. .net code)... so > > theoretically IronPython would be embeddable in an app targeting Metro > > and could be made to run on Windows RT (the O.S. Formerly know as > > Windows on ARM). > > The fact that there is so much confusion about this topic shows what a > terribly job Microsoft is doing of marketing all of this. I'm > relatively well connected, Microsoft-wise, but you presented several > tidbits I had not seen before. > > > > Windows RT (which is what they're calling the version of Windows 8 > > that runs on ARM) is to Windows 8 what Android is to Linux. It's > > a very restricted, tightly controlled environment. It's Windows > > for Phones, not just another port of Windows desktop. > > > > > > Just to be clear I referred to Windows RT the OS as Windows on ARM to > > be less confusing with Windows Runtime the programming API for Metro > > Style Apps. > > Yes, me, too. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jim at maplesong.com Thu Jun 28 21:28:28 2012 From: jim at maplesong.com (Jim Carroll) Date: Thu, 28 Jun 2012 19:28:28 +0000 (UTC) Subject: [python-win32] =?utf-8?q?pywintypes_assert_sys=2Emodules=5Bmodnam?= =?utf-8?q?e=5D_is_old=5Fmod?= Message-ID: I'm running django1.2.4 against mssql, using sqlserver_ado,and pywin32 v214 and it runs for a few hours, then starts failing with: File "C:\\Python27\\lib\\site-packages\\django_mssql-1.0.0.dev_unknown- py2.7.egg\\sqlserver_ado\\dbapi.py", line 41, in import pythoncom File "C:\\Python27\\lib\\site-packages\\pythoncom.py", line 2, in import pywintypes File "C:\\Python27\\lib\\site- packages\\win32\\lib\\pywintypes.py", line 124, in __import_pywin32_system_module__("pywintypes", globals()) File "C:\\Python27\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 114, in __import_pywin32_system_module__ assert sys.modules[modname] is old_mod >From what I've read, going back to version 212 solves the problem, so I'm trying that now. I was using 214 It seems like there must be two similar dlls loading, and the second to load is failing. Can anyone tell me which dll in particular I can look for duplicates of, maybe I can blindly find all version on the machine, and replace older versions with the latest. Thanks! From rupole at hotmail.com Thu Jun 28 22:28:10 2012 From: rupole at hotmail.com (Roger Upole) Date: Thu, 28 Jun 2012 16:28:10 -0400 Subject: [python-win32] pywintypes assert sys.modules[modname] is old_mod References: Message-ID: Jim Carroll wrote: > I'm running django1.2.4 against mssql, using sqlserver_ado,and pywin32 v214 > and it runs for a few hours, then starts failing with: > > > File "C:\\Python27\\lib\\site-packages\\django_mssql-1.0.0.dev_unknown- > py2.7.egg\\sqlserver_ado\\dbapi.py", line 41, in import pythoncom > File "C:\\Python27\\lib\\site-packages\\pythoncom.py", line 2, in > import pywintypes File "C:\\Python27\\lib\\site- > packages\\win32\\lib\\pywintypes.py", line 124, in > __import_pywin32_system_module__("pywintypes", globals()) File > "C:\\Python27\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 114, in > __import_pywin32_system_module__ assert sys.modules[modname] is old_mod > > > >>From what I've read, going back to version 212 solves the problem, so > I'm trying that now. I was using 214 > > It seems like there must be two similar dlls loading, and the > second to load is failing. Can anyone tell me which dll in > particular I can look for duplicates of, maybe I can blindly > find all version on the machine, and replace older versions > with the latest. > > Thanks! Look for duplicate versions of pywintypes27.dll or pythoncom27.dll, most likely in the python installation and your System32 directory. Roger From jim at maplesong.com Fri Jun 29 04:19:26 2012 From: jim at maplesong.com (Jim Carroll) Date: Fri, 29 Jun 2012 02:19:26 +0000 (UTC) Subject: [python-win32] =?utf-8?q?pywintypes_assert_sys=2Emodules=5Bmodnam?= =?utf-8?q?e=5D_is_old=5Fmod?= References: Message-ID: > Look for duplicate versions of pywintypes27.dll or pythoncom27.dll, > most likely in the python installation and your System32 directory. Could pywintypes27.dll be colliding with pywintypes26.dll? I just tried moving everything to Python 2.7, and disabling python 2.6, and I seem to be getting somewhere. From rupole at hotmail.com Fri Jun 29 23:03:06 2012 From: rupole at hotmail.com (Roger Upole) Date: Fri, 29 Jun 2012 17:03:06 -0400 Subject: [python-win32] pywintypes assert sys.modules[modname] is old_mod References: Message-ID: Jim Carroll wrote: >> Look for duplicate versions of pywintypes27.dll or pythoncom27.dll, >> most likely in the python installation and your System32 directory. > > Could pywintypes27.dll be colliding with pywintypes26.dll? > I just tried moving everything to Python 2.7, > and disabling python 2.6, and I seem to be getting somewhere. It's highly unlikely that the 2.6 dll's are involved, unless python itself was somehow mislinked. Did you actually have multiple copies of the 2.7 dll's ? Roger From mmanfre at gmail.com Fri Jun 29 23:20:53 2012 From: mmanfre at gmail.com (Michael Manfre) Date: Fri, 29 Jun 2012 17:20:53 -0400 Subject: [python-win32] pywintypes assert sys.modules[modname] is old_mod In-Reply-To: References: Message-ID: I also ran in to pywin32 issues when I was migrating from Python 2.6 to Python 2.7. The stack trace you showed looks familiar, but I don't remember the exact error because this was many months ago. The problem occurred while I had both version of Python on the same system and it went away after I uninstalled Python 2.6 (and all of its extra packages). -- Michael Manfre On Thu, Jun 28, 2012 at 10:19 PM, Jim Carroll wrote: > > Look for duplicate versions of pywintypes27.dll or pythoncom27.dll, > > most likely in the python installation and your System32 directory. > > Could pywintypes27.dll be colliding with pywintypes26.dll? > I just tried moving everything to Python 2.7, > and disabling python 2.6, and I seem to be getting somewhere. > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From belsuzie at worldline.ca Sat Jun 30 04:02:26 2012 From: belsuzie at worldline.ca (lucienne roussin) Date: Fri, 29 Jun 2012 22:02:26 -0400 Subject: [python-win32] (no subject) Message-ID: <6E3997DCDEB84522BEE5E63521D5A3BB@robertPC> An HTML attachment was scrubbed... URL: From jim at maplesong.com Sat Jun 30 15:57:42 2012 From: jim at maplesong.com (Jim Carroll) Date: Sat, 30 Jun 2012 13:57:42 +0000 (UTC) Subject: [python-win32] =?utf-8?q?pywintypes_assert_sys=2Emodules=5Bmodnam?= =?utf-8?q?e=5D_is_old=5Fmod?= References: Message-ID: > Did you actually have multiple copies of the 2.7 dll's ? Not really... Just in the usual places: >>> find = ['pywintypes.py', 'pywintypes27.dll', 'pythoncom27.dll'] >>> for (path,dirs,files)in os.walk('\\'): ... for f in find: ... if f in files: print "%s in %s" % (f, path) ... pywintypes.py in \Documents and Settings\aldev\Desktop\pywin32-214\win32\lib pywintypes27.dll in \Python27\Lib\site-packages\pywin32_system32 pythoncom27.dll in \Python27\Lib\site-packages\pywin32_system32 pywintypes.py in \Python27\Lib\site-packages\win32\lib pywintypes27.dll in \WINDOWS\system32 pythoncom27.dll in \WINDOWS\system32 >>> I am trying to uninstall al of Python26 though. For a while I was getting the error despite commenting out the asserts at the bottom of pywintypes.py, even after a reboot and deleting the pyc and pyos! So something is getting cached.