Jun-28-2024, 03:19 PM
subprocess.run raises an exception when it cannot start the subprocess. It does not raise an exception when powershell has a problem running a script. That is why you look at stderr and the return code.
You can configure the run() call to raise an exception when the return code is not zero (check).
According to the documentation, your code is wrong.
You can configure the run() call to raise an exception when the return code is not zero (check).
According to the documentation, your code is wrong.
Quote:args is required for all calls and should be a string, or a sequence of program arguments. Providing a sequence of arguments is generally preferred, as it allows the module to take care of any required escaping and quoting of arguments (e.g. to permit spaces in file names). If passing a single string, either shell must be True (see below) or else the string must simply name the program to be executed without specifying any arguments.You are passing a single string, but the string is not just the command to be executed.