0

I have a service that executes a .bat file that calls a python program. The python program includes the win32com module.

If the service is run as session 0 it fails somewhere deep in win32com.

However, if the service is run as session != 0, it executes OK. Similarly, if the .bat file is executed from a cmd window at the desktop it runs OK.

Any thoughts about why this is happening?

  • Is it really that it won't run in session 0, or that it won't run using a service account? (Try configuring the service to run using a real user account and see if it makes any difference.) – Harry Johnston Jun 20 '15 at 08:18
  • Service configured to run as user. FireDaemon Pro used to create all services. All services run OK except for this one. FDPro has the option to "Start (in session)" or "Start" and then "Switch To Session0". When I Start and Switch To Session 0 I can see that the process fails. If I Start (in session), then the service works as long as RDC is running. Batch program works from command window. But if RDC is killed while batch runs, then reconnected later, log file shows that batch program fails while RDC disconnected but works again as soon as RDC connection reestablished. – user1668844 Jun 26 '15 at 19:18
  • I can't imagine what "start and switch to session 0" can mean - processes can't move between sessions. Try using an ordinary service, without FDPro in the mix - the easiest way to do this for testing is to use psexec (available for download from the MS web site) to run the batch file. – Harry Johnston Jun 26 '15 at 22:13
  • This problem is there even if not run as a service. If RDC to server and run .bat file in a cmd window, .bat file (which runs a queue that'll keep running forever) runs OK. If disconnect from server while .bat is running, .bat execution fails. However, if later reconnect to server while .bat is running, then as soon as reconnected, .bat starts to work again properly. – user1668844 Jun 29 '15 at 09:22
  • That helps - it means this is a bug in Python, not related to sessions or services or user accounts. Does it also occur on a desktop machine if you use Switch User? (That would be an even simpler demonstration of the problem.) Anyway, I recommend that you delete this question and post a new one on that basis, tagged python. Alternatively, presumably the Python developers have some kind of bug reporting system, you might try there. It would be helpful if you can come up with an MCVE, a short Python program that exhibits the problem. – Harry Johnston Jun 29 '15 at 21:20

0 Answers0