I have a program which calls Windows CLI commands via subprocess.call():
import subprocess
def syscall(*cmd):
cmd = ['cmd','/d','/c']+list(cmd)
subprocess.call(cmd)
When I compile it with pyinstaller and start the executable via
desktop-click, it throws an exception:
Traceback (most recent call last):
File "\\VBOXSRV\python\W10\fexit_20250325_1641.py", line 3468, in <module> wexit(main())
File "\\VBOXSRV\python\W10\fexit_20250325_1641.py", line 281, in main menu()
File "\\VBOXSRV\python\W10\fexit_20250325_1641.py", line 376, in menu cls()
File "\\VBOXSRV\python\W10\fexit_20250325_1641.py", line 3366, in cls
syscall('cls')
File "\\VBOXSRV\python\W10\fexit_20250325_1641.py", line 3373, in syscall
subprocess.call(cmd)
File "subprocess.py", line 345, in call
File "subprocess.py", line 966, in __init__
File "subprocess.py", line 1435, in _execute_child
OSError: [WinError 740] The requested operation requires elevation
Why/which "elevation"?
There is no such error when I run this programm from a cmd.exe or
cygwin/bash window.
There is also no error when I I replace subprocess.call() with os.system()
but then I have to use a simple string as argument and cannot use a list of
strings.
I am using Windows 10 with:
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
--
Ullrich Horlacher Server und Virtualisierung
Rechenzentrum TIK
Universitaet Stuttgart E-Mail:
horl...@tik.uni-stuttgart.de
Allmandring 30a Tel:
++49-711-68565868
70569 Stuttgart (Germany) WWW:
https://www.tik.uni-stuttgart.de/
REF:<
20250325173...@tik.uni-stuttgart.de>