Assumming a standard configuration, the answer is no, it is not required. You can include the batch file in the lpCommandLine
argument. The remaining arguments just follow the batch file with quotes where needed.
test.cmd
@echo off
setlocal enableextensions disabledelayedexpansion
echo %1
echo %~1
echo %2
echo %~2
test.c
#define _WIN32_WINNT 0x0500
#include <windows.h>
void main(void){
// Spawn process variables
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
CreateProcess(
NULL
, "\"test.cmd\" \"x=1 y=2\" \"x=3 y=4\""
, NULL
, NULL
, TRUE
, 0
, NULL
, NULL
, &si
, &pi
);
WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
};
Output
W:\>test.exe
"x=1 y=2"
x=1 y=2
"x=3 y=4"
x=3 y=4