From cappy2112 at gmail.com Tue Oct 1 21:03:23 2013 From: cappy2112 at gmail.com (Tony Cappellini) Date: Tue, 1 Oct 2013 12:03:23 -0700 Subject: [python-win32] Understanding "Access Denied" when calling win32process.TerminateProcess() from Run As Administrator prompt Message-ID: When running from a *"Run As Administrator"* prompt on Windows 7 Professional 32-Bit, my Top-level python script spawns a process (which is another python script) using os.spawnv( ) When the top-level script ends, it attemps to call win32process.TerminateProcess() with the handle that was created during the os.spawnv() call. win32process.TerminateProcess(self._handle, exitCode) pywintypes.error: (5, 'TerminateProcess', 'Access is denied.') is displayed. This runs on Windows XP just fine. Obviusly, Windows 7 is more stringent with security concerns. We use Python 2.3, so subprocess and multiprocess are not available. I don't understand why this is an issue when running from the "Run As Administrator" prompt. Are there any other workarounds- until we migrate to Python 2.7? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Tue Oct 1 21:57:36 2013 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 1 Oct 2013 21:57:36 +0200 Subject: [python-win32] Understanding "Access Denied" when calling win32process.TerminateProcess() from Run As Administrator prompt In-Reply-To: References: Message-ID: Hi! "Run As Administrator" prompt on Windows 7 has several oddities. e.g. if you have mapped disks (on LAN), try to do DIR R: with command-line "As Administrator" and "As User" ...and you the problem. @-salutations -- Michel Claveau ----- Original Message ----- From: Tony Cappellini To: python-win32 at python.org Sent: Tuesday, October 01, 2013 9:03 PM Subject: [python-win32] Understanding "Access Denied" when calling win32process.TerminateProcess() from Run As Administrator prompt When running from a "Run As Administrator" prompt on Windows 7 Professional 32-Bit, my Top-level python script spawns a process (which is another python script) using os.spawnv( ) When the top-level script ends, it attemps to call win32process.TerminateProcess() with the handle that was created during the os.spawnv() call. win32process.TerminateProcess(self._handle, exitCode) pywintypes.error: (5, 'TerminateProcess', 'Access is denied.') is displayed. This runs on Windows XP just fine. Obviusly, Windows 7 is more stringent with security concerns. We use Python 2.3, so subprocess and multiprocess are not available. I don't understand why this is an issue when running from the "Run As Administrator" prompt. Are there any other workarounds- until we migrate to Python 2.7? Thanks ------------------------------------------------------------------------------ _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Wed Oct 2 00:44:42 2013 From: mc at mclaveau.com (Michel Claveau) Date: Wed, 2 Oct 2013 00:44:42 +0200 Subject: [python-win32] Understanding "Access Denied" when callingwin32process.TerminateProcess() from Run As Administrator prompt In-Reply-To: References: Message-ID: <150A3202FE584BF3BBD9F316A470D422@M14> Re ! The best (for me) solution: down the UAC-level to zero... @-salutations -- Michel Claveau ----- Original Message ----- From: Michel Claveau To: cappy2112 at gmail.com ; python-win32 at python.org Sent: Tuesday, October 01, 2013 9:57 PM Subject: Re: [python-win32] Understanding "Access Denied" when callingwin32process.TerminateProcess() from Run As Administrator prompt Hi! "Run As Administrator" prompt on Windows 7 has several oddities. e.g. if you have mapped disks (on LAN), try to do DIR R: with command-line "As Administrator" and "As User" ...and you the problem. @-salutations -- Michel Claveau ----- Original Message ----- From: Tony Cappellini To: python-win32 at python.org Sent: Tuesday, October 01, 2013 9:03 PM Subject: [python-win32] Understanding "Access Denied" when calling win32process.TerminateProcess() from Run As Administrator prompt When running from a "Run As Administrator" prompt on Windows 7 Professional 32-Bit, my Top-level python script spawns a process (which is another python script) using os.spawnv( ) When the top-level script ends, it attemps to call win32process.TerminateProcess() with the handle that was created during the os.spawnv() call. win32process.TerminateProcess(self._handle, exitCode) pywintypes.error: (5, 'TerminateProcess', 'Access is denied.') is displayed. This runs on Windows XP just fine. Obviusly, Windows 7 is more stringent with security concerns. We use Python 2.3, so subprocess and multiprocess are not available. I don't understand why this is an issue when running from the "Run As Administrator" prompt. Are there any other workarounds- until we migrate to Python 2.7? Thanks ---------------------------------------------------------------------------- _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 ------------------------------------------------------------------------------ _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Oct 2 14:48:58 2013 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 02 Oct 2013 13:48:58 +0100 Subject: [python-win32] Understanding "Access Denied" when calling win32process.TerminateProcess() from Run As Administrator prompt In-Reply-To: References: Message-ID: <524C163A.4090407@timgolden.me.uk> On 01/10/2013 20:03, Tony Cappellini wrote: > > When running from a *"Run As Administrator"* prompt on Windows 7 > Professional 32-Bit, > > my Top-level python script spawns a process (which is another python > script) using os.spawnv( ) > > When the top-level script ends, it attemps to call > win32process.TerminateProcess() with the handle > that was created during the os.spawnv() call. > > win32process.TerminateProcess(self._handle, exitCode) > pywintypes.error: (5, 'TerminateProcess', 'Access is denied.') Well, slightly oddly, this is the error message you receive when you try to terminate a process which has already terminated! I don't know if this behaviour is new to Win7 (and I'm reluctant to build a WinXP VM just to test one line of code :) ). Could that be the answer? TJG From s at vtwireless.com Mon Oct 7 23:08:13 2013 From: s at vtwireless.com (Stan) Date: Mon, 7 Oct 2013 17:08:13 -0400 Subject: [python-win32] Issues with service startup Message-ID: Has anyone dealt with Python based Windows Services not starting properly at system boot? They start immediately after boot, but not at boot. Attempting to use various dependencies to make it start up later in the process hasn't seemed to help. I have to separate codebases that exhibit this issue, their commonality is they both connect to a PostgreSQL database on the machine, and use multiprocessing and threading. I don't have the issue narrowed down to a test case that exhibits the issue, but it occurs on some systems every single time, and on others only intermittently. For one of the two, delaying at service startup (sleep...) before importing wmi and pythoncom libraries seemed to cause it to stop failing at startup. The other does not seem to use wmi/pythoncom directly. Event Type: Error Event Source: Service Control Manager Event Category: None Event ID: 7009 Date: 10/5/2013 Time: 2:35:49 PM User: N/A Computer: WINDOWSTEST1 Description: Timeout (30000 milliseconds) waiting for the MyTestApp1 service to connect. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. Event Type: Error Event Source: Service Control Manager Event Category: None Event ID: 7000 Date: 10/5/2013 Time: 2:35:49 PM User: N/A Computer: WINDOWSTEST1 Description: The MyTestApp1 service failed to start due to the following error: The service did not respond to the start or control request in a timely fashion. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Tue Oct 8 09:09:31 2013 From: vernondcole at gmail.com (Vernon D. Cole) Date: Tue, 8 Oct 2013 01:09:31 -0600 Subject: [python-win32] Issues with service startup In-Reply-To: References: Message-ID: This answer is a bandage, not a cure, but perhaps it will be enough in your case... The first moments of operation when a system (especially a server) is booting up are replete with programs demanding resources which may not be available yet. I found that simply adding a Python time.sleep() call near the beginning of my program made the difference in reliability. If you feel that package initialization may be part of the problem, remember that in Python "import" is an executed statement. We often treat it as if it were a compiler declaration, but it is not. So if you... >>>import time >>>print('Waiting for system to settle down...') >>>time.sleep(30) >>>import big_package then "big_package" will not be imported until after things settle down. I hope you find out what is *really* causing your problem, but until then, try the quick and dirty work-around. -- Vernon On Mon, Oct 7, 2013 at 3:08 PM, Stan wrote: > Has anyone dealt with Python based Windows Services not starting properly > at system boot? They start immediately after boot, but not at boot. > Attempting to use various dependencies to make it start up later in the > process hasn't seemed to help. > > I have to separate codebases that exhibit this issue, their commonality is > they both connect to a PostgreSQL database on the machine, and use > multiprocessing and threading. > > I don't have the issue narrowed down to a test case that exhibits the > issue, but it occurs on some systems every single time, and on others only > intermittently. > > For one of the two, delaying at service startup (sleep...) before > importing wmi and pythoncom libraries seemed to cause it to stop failing at > startup. The other does not seem to use wmi/pythoncom directly. > > Event Type: Error > Event Source: Service Control Manager > Event Category: None > Event ID: 7009 > Date: 10/5/2013 > Time: 2:35:49 PM > User: N/A > Computer: WINDOWSTEST1 > Description: > Timeout (30000 milliseconds) waiting for the MyTestApp1 service to connect. > > For more information, see Help and Support Center at > http://go.microsoft.com/fwlink/events.asp. > > Event Type: Error > Event Source: Service Control Manager > Event Category: None > Event ID: 7000 > Date: 10/5/2013 > Time: 2:35:49 PM > User: N/A > Computer: WINDOWSTEST1 > Description: > The MyTestApp1 service failed to start due to the following error: > The service did not respond to the start or control request in a timely > fashion. > > For more information, see Help and Support Center at > http://go.microsoft.com/fwlink/events.asp. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joss.gray at d3technologies.com Tue Oct 8 12:48:33 2013 From: joss.gray at d3technologies.com (Joss Gray) Date: Tue, 8 Oct 2013 11:48:33 +0100 Subject: [python-win32] Python Service Session 0 Message-ID: Has anybody been able to get a python service running outside of session 0? -- *Joss Gray* -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Oct 12 21:54:10 2013 From: timr at probo.com (Tim Roberts) Date: Sat, 12 Oct 2013 12:54:10 -0700 Subject: [python-win32] Python Exe is not running on Windows 2003 In-Reply-To: References: Message-ID: <5259A8E2.9020305@probo.com> manu agarwal wrote: > > I have written the Python script that used to get the CPU usage,RAM > and Disk usage from the windows server. > > Then i converted the script to exe through to execute on server. The psutil module is not included with Python. Did you build it yourself, or did you download a binary? On what operating system and with which compilers did you build it? Several of the functions in PSAPI.DLL moved between Vista and Windows 7. As long as it is compiled with the right options, it should link properly on both older and newer systems. However, the psutil build process sets the version macros to match the system where it is built. Thus, if you build psutil on a Windows 7 system, I believe it will expect the new naming, which doesn't work prior to Vista. Thus, I think you can fix this in the "setup.py" for the psutil module, by adding the following to the "define_macros" list: ('PSAPI_VERSION', '1') However, I have not tried this myself. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nmanu14387 at gmail.com Sat Oct 12 09:14:25 2013 From: nmanu14387 at gmail.com (manu agarwal) Date: Sat, 12 Oct 2013 12:44:25 +0530 Subject: [python-win32] Python Exe is not running on Windows 2003 Message-ID: Hi , I have written the Python script that used to get the CPU usage,RAM and Disk usage from the windows server. Then i converted the script to exe through to execute on server. The exe is running fine on windows 2008 sever but it is giving an error while executing on windows 2003. Below is the error : C:\dist>Monitor_server.exe Traceback (most recent call last): File "Monitor_server.py", line 9, in File "psutil\__init__.pyo", line 85, in File "psutil\_psmswindows.pyo", line 15, in File "_psutil_mswindows.pyo", line 12, in File "_psutil_mswindows.pyo", line 10, in __load ImportError: DLL load failed: The specified procedure could not be found. Please assist Thanks Manu Agarwal -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew.george.hammond at gmail.com Tue Oct 15 03:56:42 2013 From: andrew.george.hammond at gmail.com (Andrew Hammond) Date: Mon, 14 Oct 2013 18:56:42 -0700 Subject: [python-win32] determining service startType Message-ID: Hi All, I know how to change a service's configuration to manipulate the startType using win32serviceutil.ChangeServiceConfig('my_service', startType=4) # disable for example, but how do I query the current startType? Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From daverz at gmail.com Mon Oct 28 14:52:38 2013 From: daverz at gmail.com (Dave Cook) Date: Mon, 28 Oct 2013 06:52:38 -0700 Subject: [python-win32] Sending raw bytes with DDE server Message-ID: I have to interface some Python code with some ancient DDE clients. One of the Requests requires a struct. I tried using the struct.pack from the struct module, but data gets cut off at the first inevitable NULL byte. class MyTopic(object.Object): def __init__(self, topicName): topic = dde.CreateTopic(topicName) topic.AddItem(dde.CreateStringItem("")) object.Object.__init__(self, topic) self.topicName = topicName def Request(self, req): if req=='STATUS': vals = range(1, 5) result = struct.pack('lffff', *vals) return result -------------- next part -------------- An HTML attachment was scrubbed... URL: From daverz at gmail.com Mon Oct 28 14:55:51 2013 From: daverz at gmail.com (Dave Cook) Date: Mon, 28 Oct 2013 06:55:51 -0700 Subject: [python-win32] Sending raw bytes with DDE server In-Reply-To: References: Message-ID: On Mon, Oct 28, 2013 at 6:52 AM, Dave Cook wrote: > I have to interface some Python code with some ancient DDE clients. One > of the Requests requires a struct. I tried using the struct.pack from the > struct module, but data gets cut off at the first inevitable NULL byte. > > class MyTopic(object.Object): > > def __init__(self, topicName): > topic = dde.CreateTopic(topicName) > topic.AddItem(dde.CreateStringItem("")) > object.Object.__init__(self, topic) > self.topicName = topicName > > def Request(self, req): > if req=='STATUS': > vals = range(1, 5) > result = struct.pack('lffff', *vals) > return result > Sorry, got cut off. Last bit should be as above. Dave Cook -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Oct 28 18:56:15 2013 From: timr at probo.com (Tim Roberts) Date: Mon, 28 Oct 2013 10:56:15 -0700 Subject: [python-win32] Sending raw bytes with DDE server In-Reply-To: References: Message-ID: <526EA53F.3000301@probo.com> Dave Cook wrote: > I have to interface some Python code with some ancient DDE clients. > One of the Requests requires a struct. I tried using the struct.pack > from the struct module, but data gets cut off at the first inevitable > NULL byte. You're sure the client wants binary, and not some ASCII encoding of the binary? That was a common strategy in the days when DDE was popular (that is, during the reign of the 80386). Your assessment is correct. The PyWin32 DDE support is string only. If you really need binary, then you will have to write a DLL helper. The ctypes module might help. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From daverz at gmail.com Mon Oct 28 21:47:16 2013 From: daverz at gmail.com (Dave Cook) Date: Mon, 28 Oct 2013 13:47:16 -0700 Subject: [python-win32] Sending raw bytes with DDE server In-Reply-To: <526EA53F.3000301@probo.com> References: <526EA53F.3000301@probo.com> Message-ID: On Mon, Oct 28, 2013 at 10:56 AM, Tim Roberts wrote: > > You're sure the client wants binary, and not some ASCII encoding of the > binary? That was a common strategy in the days when DDE was popular > (that is, during the reign of the 80386). > > Your assessment is correct. The PyWin32 DDE support is string only. If > you really need binary, then you will have to write a DLL helper. The > ctypes module might help. > Thanks, guys. I do have he original C code for the DDE server, so if I have to I can wrap that. Here is where it creates the return value for the request. hddedata = DdeCreateDataHandle( g_service.dwIdInst, (LPBYTE)&status, sizeof( REMOTESTATUS ) + 1, 0, hszItem, CF_TEXT, 0 ); Where REMOTESTATUS is the data struct and hddedata is of type HDDEDATA. CF_TEXT is the clipboard format. So it seems that what I need to do is encode the data into clipboard format. Dave Cook -------------- next part -------------- An HTML attachment was scrubbed... URL: From daverz at gmail.com Tue Oct 29 00:09:50 2013 From: daverz at gmail.com (Dave Cook) Date: Mon, 28 Oct 2013 16:09:50 -0700 Subject: [python-win32] Encoding bytes in clipboard format (was: Sending raw bytes with DDE server) Message-ID: > On Mon, Oct 28, 2013 at 10:56 AM, Tim Roberts wrote: > >> >> You're sure the client wants binary, and not some ASCII encoding of the >> binary? That was a common strategy in the days when DDE was popular >> (that is, during the reign of the 80386). >> >> Your assessment is correct. The PyWin32 DDE support is string only. If >> you really need binary, then you will have to write a DLL helper. The >> ctypes module might help. >> > So it looks like I need to encode my data as CF_TEXT (clipboard format). Any hints on how I can encode a byte string as CF_TEXT? Not for use on the clipboard, but for sending as the return value for a DDE request. Thanks, Dave Cook -------------- next part -------------- An HTML attachment was scrubbed... URL: From toreklars at gmail.com Thu Oct 31 16:59:46 2013 From: toreklars at gmail.com (Tore Klars) Date: Thu, 31 Oct 2013 08:59:46 -0700 Subject: [python-win32] LocalService, COM Message-ID: I'm debugging a COM issue with pythoncom: a Python program is unable communicate with VirtualBox over COM when run under the LocalService or NetworkService Windows accounts. The same program can communicate with VirtualBox without issue under the LocalSystem, administrator, and Guest accounts. Under LocalService and NetworkService, this line win32com.client.Dispatch('VirtualBox.VirtualBox') raises com_error(-2147024891, 'Access is denied.', None, None) Why are the LocalService and NetworkService accounts unable to communicate with VirtualBox over COM? Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From RDahlstrom at directedge.com Thu Oct 31 17:45:36 2013 From: RDahlstrom at directedge.com (Dahlstrom, Roger) Date: Thu, 31 Oct 2013 12:45:36 -0400 Subject: [python-win32] LocalService, COM In-Reply-To: References: Message-ID: <78C91C6FD63DD04BB8812EE9288C1E8135576A8409@EXCHANGE01.office.directedge.net> Because both LocalService and NetworkService have minimal privileges on the local computer, while LocalSystem, admin, and guest have more extensive privileges. From: python-win32 [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Tore Klars Sent: Thursday, October 31, 2013 12:00 PM To: python-win32 at python.org Subject: [python-win32] LocalService, COM I'm debugging a COM issue with pythoncom: a Python program is unable communicate with VirtualBox over COM when run under the LocalService or NetworkService Windows accounts. The same program can communicate with VirtualBox without issue under the LocalSystem, administrator, and Guest accounts. Under LocalService and NetworkService, this line win32com.client.Dispatch('VirtualBox.VirtualBox') raises com_error(-2147024891, 'Access is denied.', None, None) Why are the LocalService and NetworkService accounts unable to communicate with VirtualBox over COM? Thank you. ________________________________ DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. Direct Edge may, at its discretion, monitor and review the content of all e-mail communications. -------------- next part -------------- An HTML attachment was scrubbed... URL: