#include #include int main() { STARTUPINFO si = { sizeof(si)}; PROCESS_INFORMATION pi = {0}; // create the custom env char custom_env[] = "MY_VAR=HELLOCHILD\0\0"; if(CreateProcess("C:\\Windows\\System32\\notepad.exe",NULL,NULL,NULL,FALSE,0,custom_env,NULL,&si,&pi)) { printf("process created successfully\n"); printf("Process ID: %lu\n",pi.dwProcessId); // close handle CloseHandle(pi.hProcess); CloseHandle(pi.hThread); getchar(); } else { printf("Error: %lu\n",GetLastError()); return 1; } return 0; }