[python-win32] win32 Service and Networkdrive Trouble...

Sergej Pioch sergej.pioch at rz.uni-freiburg.de
Thu Aug 28 16:14:12 EDT 2003


Hello everybody,

I'm pretty new to python and I try to write a UPS-Software. The Script 
should run as a windows service and get Information from a network 
device, in this case a mapped network drive. It should search for a file 
<hostname>.bat and run the command contained in it as a systemcall (i.e. 
a 'shutdown -s -f  -t 0').

Almost everything works fine, as long as I use the Python interactive 
commandline or the script itself for testing. Run as service, the script 
cannot find the specified Path - neither if the script is started as 
user 'SERVICE' nor in any other Account. The eventlog shows the 
following errormessage:

 >> The instance's SvcRun() method failed
      File 
"C:\Python22\Lib\site-packages\win32\lib\win32serviceutil.py", line 635, 
in SvcRun
      self.SvcDoRun()
      File "PATH_TO_PROGRAM", line 40, in SvcDoRun
      None)
      pywintypes.api_error: (3, 'CreateFile', 'The system cannot find 
the path specified.')

And here is a snipplet of the services mainloop:

 >> while X==1:
            rc = win32event.WaitForSingleObject(self.hWaitStop, 1)
            if rc==win32event.WAIT_OBJECT_0:
                break
            else:
                Content = CreateFile(\
                    Directory,\
                    GENERIC_READ,\
                    FILE_SHARE_READ,\
                    None,\
                    OPEN_EXISTING,\
                    0,\
                    None)
                Action = ReadFile(Content, 256)
                Content.Close()
                if Action[0]==0:
                    os.system(Action[1])
                    X=0
                else:
                    continue

where Directory is a predefined value. I took everything out of the book 
'Python on Win32 programming' and nailed it all together. Since I worked 
on it for four days now and got no clue how to fix this I thought it 
would be better to contact a mailinglist for help.

Has anyone any idea?


Best


Sergej





More information about the Python-win32 mailing list