The problem is whenever I’m trying to restart my code with admin rights, it starts with python 3.7. Basically I just want to access admin rights not switching any versions. But according to my arguments and prints that I made, it should be python 3.12, which I currently use. I’ve tried using pyuac and some others options but it still has same result.
The code:
import win32com.shell.shell as shell
import win32con
shell.ShellExecuteEx(
lpVerb='runas',
lpFile='"' + sys.executable + '"',
nShow=win32con.SW_NORMAL,
lpParameters=' '.join(args)
)
The command that i used:
C:UsersUsernamePycharmProjectsMy-project>python3.12 main.py "-startAsAdmin"
Output before restarting:
C:UsersUsernameAppDataLocalMicrosoftWindowsAppsPythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0python.exe
Output after restarting:
C:UsersUsernameAppDataLocalMicrosoftWindowsAppsPythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0python.exe
NBomb is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1