How to escape space when using mel's system command?

I am trying to learn how to run external processes from within maya, I am struggling to escape space, I have so far tried:

system("\"C:/my folder/programme.exe\"");

While the above works, the programme does run but as soon as I try to provide a file or arguments to the programme I start to run into issues:

system("'C:/my folder/programme.exe' 'C:/my folder/out.png''");
system('"C:/my folder/programme.exe" "C:/my folder/out.png"');
system("\"C:/my folder/programme.exe\" \"C:/my folder/out.png\"");
system("\"C:/my folder/programme.exe\" \"C:/my folder/out.png\"");

With all the above I get a syntax error. I am not sure where I am going wrong here. ChatGPT keeps telling me to use CMD withing system(), I would like to avoid this as I am interested in learning how to do this directly with Mel.

It turns out I was missing a start keyword:

system("start \"C:/my folder/programme.exe\" \"C:/my folder/out.png\"

A user on [reddit pointed me to ](``` mel wiki - - Your Maya : Mel : Python : PyMel : API : scripting resource on the web -), which helped.

1 Like