Use subprocess and advise
run()
function for all use cases it can handle.import subprocess result = subprocess.run(['ipconfig'], encoding='utf-8', capture_output=True) print(result.stdout)No force it to
utf-8
(Python's default encoding),Windows can sometime use charmap
encoding when call external stuff.