#include <windows.h>
#include <stdio.h>
#include <string.h>

int main(int argc, LPTSTR argv[]) {
    
    STARTUPINFO startinfo;
    PROCESS_INFORMATION processinfo;
    LPTSTR lpCommandLine;
    
    ZeroMemory(&startinfo, sizeof(startinfo));
    startinfo.cb = sizeof(startinfo);
    strcpy(lpCommandLine, "c:\\WINDOWS\\SYSTEM32\\NOTEPAD.EXE temp.txt");
    
    if(!CreateProcess(NULL, lpCommandLine, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE, NULL, NULL, &startinfo, &processinfo)) {
        printf("CreateProcess failed on error %d\n", GetLastError());
        ExitProcess(1);
    }
    
    //WaitForSingleObject(processinfo.hProcess, INFINITE);
    
    CloseHandle(&processinfo.hThread);
    CloseHandle(&processinfo.hProcess);
}
