<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>I have spent some hours trying to find a problem when using Unix.create_process in windows.<br><br></div>The problem shows when trying to create a process in which the path of the executable and one of the arguments have spaces, for example:<br><br></div>let cmd = "C:/Program Files/Something/something.exe" ;;<br>let args = ["arg1"; "arg2"; "C:/Program Files/arg3"] ;;<br><br>let pid = Unix.create_process cmd (cmd::args |> Array.of_list) Unix.stdin Unix.stdout Unix.stderr ;;<br><br>Unix.waitpid [] pid ;;<br><br></div>As soon as there's an argument with spaces, the process fails to run. I tried many different combinations with quoting, backlashes, forwardslashes, backslashed space, etc, but nothing seemed to work.<br><br></div>I saw that ocaml calls CreateProcess from the windows API, which has many weird things in the documentation. <br><div><div><div><br></div><div>When calling CreateProcess you need to supply (optionally) the path to the application and then the full command line call. For example:<br><br></div><div>CreateProcess("C:/some.exe","\"C:/some.exe\" arg1 arg2",.........);<br><br></div><div>Note that you need to pass in the full command line the name of the application quoted.<br><br></div><div>The only way of fixing my problem was to pass NULL as first argument:<br><br>CreateProcess(NULL","\"C:/some.exe\" arg1 arg2",.........);<br></div><div><br></div><div>After making this change all calls work fine for me. <br><br></div><div>Has anyone had these kind of problems?<br><br></div><div>Is is possible to get this change in the ocaml code?<br><br></div><div>Leonardo<br></div><div><br><br></div></div></div></div>