[python-win32] wrong results in service running mode

Mark Hammond mhammond at skippinet.com.au
Thu Apr 20 01:01:43 CEST 2006

> One piece of the program is to check a file exist or not as follows:
>          szNormPath= os.path.normpath(strFileName)
>          nRetCode = os.access(szNormPath, os.F_OK)
>          # nRetCode = os.path.exists(szNormPath)
> When the file path is C:\shared\t.txt, no problem.
> When the path becomes L:\t.txt, then I got problems:
> nRetCode always is False(0), here L: is a mapped drive
> L: = C:\shared. So L:\t.txt and C:\shared\t.txt
> point to the same file.

This is almost an FAQ for services and has nothing to do with Python.

When running from a DOS box, the service is running as your user, so has all
your drive mappings etc.  When running as a service it generally runs as a
different user, so does not.  Worse, the LocalSystem account generally has
no network access.

The solution is generally just to use the complete UNC name '\\server\share'
in your Python program - this generally works fine (but still will generally
*not* work for the LocalSystem account - so you will also need to change the



More information about the Python-win32 mailing list