Python os.sytem() and Windows Program Files directory

I ran across a problem when trying to run a program located in “Program Files” directory from within a Python application using os.system(). It was obvious that the problem was caused by the space character in the name of the directory. I didn’t know how to solve the issue as I’m not proficient in Python and also not very comfortable in the Windows environment. Luckily, once again, there were others before me, who had found the way:

 os.system( '""C:\\\\Program Files\\\\WinProgram\\\\PROGRAM.EXE" -params "')

Adding an extra pair of qotation marks did the trick.

Leave a Reply