You forgot to speficy the STARTF_USESTDHANDLES flag in siStartupInfo.dwFlags.
Change
startupInfo.dwFlags = STARTF_USESHOWWINDOW ;
to
startupInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES ;
and change
CreateProcess(0, (char*)(cmd.GetString()), 0, 0, false, 0, 0, 0,
&siStartupInfo, &piProcessInfo)
to
CreateProcess(0, (char*)(cmd.GetString()), 0, 0, true, 0, 0, 0,
&siStartupInfo, &piProcessInfo)
I suggest you read the STARTF_USESTDHANDLES section of the STARTUPINFO documentation, there is plenty of information.
BTW you should also add
CloseProcess(piProcessInfo.hProcess)
at the end.