What user do python scripts run as in windows? [duplicate] What user do python scripts run as in windows? [duplicate] python python

What user do python scripts run as in windows? [duplicate]


We've had issues removing files and directories on Windows, even if we had just copied them, if they were set to 'readonly'. shutil.rmtree() offers you sort of exception handlers to handle this situation. You call it and provide an exception handler like this:

import errno, os, stat, shutildef handleRemoveReadonly(func, path, exc):  excvalue = exc[1]  if func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES:      os.chmod(path, stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO) # 0777      func(path)  else:      raiseshutil.rmtree(filename, ignore_errors=False, onerror=handleRemoveReadonly)

You might want to try that.


I've never used Python, but I would assume it runs as whatever user executes the script.


The scripts have no special user, they just run under the currently logged-in user which executed the script.

Have you tried checking that:

  • you are trying to delete a valid path? and that
  • the path has no locked files?