Hi,

I wrote a program which runs a .bat file using os.system like: 'os.system(pathToBatFile)' and everything was good. Then I decided to turn my program into a service as opposed to being run with the command prompt showing. When my program became a service, I noticed that the os.system command to run my .bat file was no longer working. By 'not working' I mean no exception is thrown, but it was as if the line with os.system(pathToBatFile) did not exist. I was wondering why this is and if there is a way to fix this or what an alternative to using os.system to run my .bat file was?

LW . . . Lawrence

Recommended Answers

All 4 Replies

'os.system(pathToBatFile)'

Is your pathToBatFile an absolute or relative path?

Is your pathToBatFile an absolute or relative path?

absolute. if it was relative, i would have gotten some kind of exception probably.

Have you tried checking the return code of os.system?

Hi,

I tried getting the return code and it turned out to be a 1. Which indicates 'not good'. So I had the service interact with the desktop so I could see the command prompt that was coming back. After some maneuvering, I found out that my access was denied. I was trying to copy a file from a remote computer to the current one. So I went to services and the 'Log On' tab and set myself to log on as the Administrator. The os.system command worked fine after that. Thanks jlm699 for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.