I've found that python can run other programs using the subprocess module. I want to use python to run a powershell script that is in a directory location that contains spaces. How do I handle the spaces in the python script below?
import subprocess
powershellExeLocation = r"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
powershellScriptLocation = r"C:\Users\username\Documents\testPowershell.ps1"
print('running script with no spaces')
#this works
subprocess.run([powershellExeLocation, powershellScriptLocation])
#this doesn't work
print('running script with spaces')
powershellScriptLocationWithSpaces = r"C:\Users\username\path with spaces\testPowershell.ps1"
subprocess.run([powershellExeLocation, powershellScriptLocationWithSpaces])