[python-win32] win32 Service and Networkdrive Trouble...
Jim Vickroy
Jim.Vickroy at noaa.gov
Thu Aug 28 09:25:27 EDT 2003
Hello Sergej,
Until someone more knowledgeable than I responds, you might try running the
Service in debug mode (command line option 'debug' rather than 'start').
That redirects all messages (including event log messages) to the console.
Its puzzling that you can run it (successfully) from the same account that
the Service uses.
As an aside, you do not need all of those trailing backslashes in your code;
Content = CreateFile(
Directory,
GENERIC_READ,
FILE_SHARE_READ,
None,
OPEN_EXISTING,
0,
None)
should work just fine.
Sergej Pioch wrote:
> 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
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
More information about the Python-win32
mailing list