1

I have written a Python script to save time, which creates and writes files to my machine locally. (Python 3)

I've turned it into an executable using PyInstaller, but in order to execute it the executable needs permissions on their machines - and doing so manually isn't going to be easy for some of them.

It'll need both permission to run and to create files.

Is there a way I can configure the executable to grant itself permissions?

(ie. prompt the user for a the admin password or something like that).

I've searched elsewhere for an answer but I think my lack of knowledge of the correct terms for this is getting in the way.

  • If you are on MacOS, you may want to look into creating a little application using Automator that calls your code. That would allow you to set permissions connected to the application. – The Matt Feb 16 '19 at 18:35

1 Answers1

1

As far as I understand, this is achieved by running the executable as root or administrator or perhaps by use of an included script to alter whatever other permissions may be needed.

This might be useful in relation to unix systems: Bash: How to give executable permission to all the python scripts in unix? Here is a related link wherein it is highlighted as a 'Note' as to what other potential causes for 'permission errors' may be encountered: https://pyinstaller.readthedocs.io/en/stable/operating-mode.html

For windows systems, looking into the --uac-admin option will likely be useful, as it will require admin privileges before running the app.

Susie Queue
  • 36
  • 1
  • 3
  • This is great thank you so much for the detail. I have edited the question to be explicit that the script needs both permission to run and to create files. Not 100% sure but I think that can be done using a modification of the bash script in that answer. I'll mark as done loved onece I've given tested that, thanks! – originalgriefster Feb 16 '19 at 17:30