0

I've created an application (Python 3.6) with cx_Freeze and when ran as a Python command or even the executable works totally fine.

But if I make the application auto-boot on windows 10 (by creating shortcut in shell:startup) the log file it would create or write to raises PermissionError. I tried to create a workaround by checking if the file is locked, just add an increment number to the end of the file.

This also works, if I manually make a log file read only, it will create the next one and so on. But with auto boot it raises RecursionError, so it has probably absolutely no way to write to the disk.

Is there anyway without giving the application Run as administrator to be able to handle the magic of creating a log file when booting up? :)

jpeg
  • 2,372
  • 4
  • 18
  • 31
Tusk
  • 703
  • 11
  • 21

1 Answers1

0

Have you tried to let the application create the log file in the %APPDATA% directory or in the %LOCALAPPDATA%directory? You can use the following to get the path to these directories in Python:

import os
app_data_path = os.getenv('APPDATA')
local_app_data_path = os.getenv('LOCALAPPDATA')
print(app_data_path)
print(local_app_data_path)

See How can I get the path to the %APPDATA% directory in Python?

jpeg
  • 2,372
  • 4
  • 18
  • 31
  • Hey I'll get back to you on this, one of the issue would be still that I also have a version file, and that seems to be unreadable too. I might have to workaround on that if the log works in appdata. – Tusk Sep 05 '18 at 15:07
  • what if we insist to use administrator required folder? – greendino Jun 11 '20 at 23:13