How to execute powershell script from python with space in the path and parameters

Question:

Path example: C:\Users\user\Some Space\dev\sensor\

Json containing the path:

In my test environnement there were no space in the path, but now, in the production, I have some space in the path, and I’m clueless about how to execute powershell script from python with space and parameters

I tried to quote the path, without any success.

Edit: I’m sure the problem come from the powershell.exe command and not from python, because:

Don’t work in the CMD.

Answer:

I finally found, you have to put ‘ between space like this:

In python:

with path as:

without ” as Serge Ballesta explain.

Source:

How to execute powershell script from python with space in the path and parameters by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply