How to open a file through python with admin rights? If something I have Windows 10

  • one
    runas, for example - eri

1 answer 1

In the folder with your my_file.py file, create a bat file start.bat (the name can be any, the extension should be bat) In the bat file, type:

python my_file.py 

If python is not added to the environment variable, then you need to specify the full path to the python interpreter, for example:

 C:\Python27\python.exe my_file.py 

bat file can be run as administrator.

Or add to the beginning of my_file.py line:

 import os os.startfile('cmd.exe','runas')