r/cpp • u/holyblackcat • Sep 05 '26
Escaping `CreateProcess()` arguments on Windows
https://holyblackcat.github.io/blog/2026/09/05/escaping-createprocess-arguments.html
93
Upvotes
r/cpp • u/holyblackcat • Sep 05 '26
View all comments
Show parent comment
7
u/Tringi github.com/tringi Sep 05 '26
You don't have to sync it. Only a few programs actually use
argv[0]and it can be very different from the actual executable name. If you runprogram a b cfrom command line, thenargv[0]will be just "program" without the path or extension, and the program must expect that.In one of my larger programs I launch worker processes. I have the full path to the worker, but I don't know what characters it may contain, and I don't want to bother with escaping them. So I give
lpApplicationNamethat path, butlpCommandLineis just "worker.exe /Something /Something /Something".