I am encountering an unusual issue on a Windows 7 machine where my Python script works perfectly when run in PowerShell with a blue background (which I assume to be Windows PowerShell), but fails when run in PowerShell with a black background (which appears to be PowerShell Core, although it's invoked via powershell.exe).
In summary:
1. PowerShell with a blue background, launched from the Start menu, works flawlessly.
2. PowerShell with a black background, launched from "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", does not work with my script.
Here is the relevant part of my Python code:
import subprocess
rexdeskconvert_command = 'ReXdeskConvert.exe convert-folder -F mf4 -i "{}" -o "{}" -s can0 "{}"'.format(input_folder, output_folder, dbc_file_path)
subprocess.run(['powershell.exe', '-Command', rexdeskconvert_command])
This subprocess.run command works without issue in the blue background PowerShell, but fails in the black background PowerShell.
Questions:
- How can I modify my Python code to consistently work with the blue background PowerShell (Windows PowerShell), which is the environment in which my script runs correctly?
- Is there a way to set the blue background PowerShell (Windows PowerShell) as the default on my Windows 7 machine, so that scripts and commands always run in that environment?
Additional context: The script is intended to run a specific executable (ReXdeskConvert.exe) with arguments, and the necessary software is installed in the specified directories.
I'm at a loss as to why the background colour seems correlated with the script’s success, and I'd really appreciate any guidance or insight into this issue.