0

I wanted to code a small script that run a external program, but it requires admin privileges. So after a bit of research I have used modules and still stuck, not sure why it is not running as I did follow the instructions for the module etc. This is what I did up to now.

import subprocess
import pyuac
import os
import ctypes
import sys


def main():

    subprocess.run("start steam://run/228180", shell=True)

if __name__ == "__main__":
    if not pyuac.isUserAdmin():
        print("Re-launching as admin!")
        pyuac.runAsAdmin()
    else:        
        main()  # Already an admin here.
martineau
  • 119,623
  • 25
  • 170
  • 301
  • 1
    I don't think a process without admin privileges can elevate those of another (or itself), otherwise having restrictions would be worthless β€” think about it… – martineau Nov 09 '20 at 22:17
  • [User01111111110](https://stackoverflow.com/users/17101320) posted an [Answer](https://stackoverflow.com/a/69501174) saying "I had the same problem and found a solution that worked. Here is the link: [Python 3: How to use subprocess.run() as admin (windows 10)](https://stackoverflow.com/questions/60214168/python-3-how-to-use-subprocess-run-as-admin-windows-10)" – Scratte Oct 09 '21 at 08:35

0 Answers0