[go: up one dir, main page]

Menu

#751 unable to start script with win32com as windows service

v1.0 (example)
closed-invalid
nobody
None
5
2017-05-08
2017-05-08
Andes
No

Hi, I am using win32com with pywin32-220.win-amd64-py2.7.exe setup in my env. Here is my test code with win32com.client calling wmi service.

````
conn = client.GetObject('winmgmts://127.0.0.1/root/cimv2')
fcvm = conn.ExecQuery("select * from Win32_PerfFormattedData_HvStats_HyperVHypervisorLogicalProcessor")
for x in fcvm:
if x.Name == "_Total":
cpu = x.PercentTotalRunTime


````

this code can run as a script but when I install this with nssm.exe as a windows service, it cannot start. In the windows event log I can check this not running at all. Can someone point me out of this? Thanks.

Andes

Discussion

  • Mark Hammond

    Mark Hammond - 2017-05-08
    • status: open --> closed-invalid
     
  • Mark Hammond

    Mark Hammond - 2017-05-08

    This is likely to be because services run with far less permissions by default - you should arrange to catch exceptions and dump them somewhere you can see them. You might also like to resend your question to the python-win32 mailing list. You need to be subscribed to the list before you can post to it - see http://mail.python.org/mailman/listinfo/python-win32 for subscription options.

     
  • Andes

    Andes - 2017-05-08

    Thanks Mark!