CreateProcess help...

Newbie Member
21Oct2007,17:56   #1
dcer's Avatar
hi,

want i want to do is, when u right click a shortcut > and in target, it is "PROGRAM PATH"...and u can put "PROGRAM PATH" /cmd /cmd2

how would i do that in CreateProcess() function?
Code:
 CreateProcess("C\\program.exe /say hello",
 NULL,
 NULL,
 NULL,
 FALSE,
 0,
 NULL,
 NULL,
 &s,
 &p);
how would u do that?
Go4Expert Founder
21Oct2007,21:14   #2
shabbir's Avatar
Second parameter is the command line you want to pass to the exe.
Newbie Member
22Oct2007,09:57   #3
dcer's Avatar
Hi,
it seem to doesn't work -_-...in order to CreateProcess, the EXE must have /load /config test2 to load the config file when the exe opens...here's CreateProcess:

Code:
 CreateProcess("C:\\configeditor\\ceditor.exe",
 "/load /config defaultc",
 NULL,
 NULL,
 FALSE,
 0,
 NULL,
 NULL,
 &s,
 &p);
and i've tried:
Code:
 CreateProcess("C:\\configeditor\\ceditor.exe /load /config defaultc",
 NULL,
 NULL,
 NULL,
 FALSE,
 0,
 NULL,
 NULL,
 &s,
 &p);
it doesn't seem to be doing what i want it to do..because it displays an error "Config needs to be loaded.."
Go4Expert Founder
22Oct2007,10:09   #4
shabbir's Avatar
Just check ceditor if it supports the command line you are providing because createprocess is a tried and tested over time and there is nothing you can do where the API can go wrong and all you need to be doing is pass the parameters correctly.
Newbie Member
22Oct2007,10:46   #5
dcer's Avatar
Hi,

i am positive because i entered it in the TARGET(shortcut >properties) and in start >run "PROGRAM" /load /config defaultc

i write a test program in autoit...
http://www.wikifortio.com/165615/test.zip

unzip and write in start > run "PATH TO test.exe" hello...it will display a msgbox "HELLO TGHERE"
i tried doing with CreateProcess..it doesn't work

Code:
CreateProcess("C:\\test.exe",
 "hello",
 NULL,
 NULL,
 FALSE,
 0,
 NULL,
 NULL,
 &s,
 &p);
Go4Expert Founder
22Oct2007,17:21   #6
shabbir's Avatar
The code below works for me
Code:
    STARTUPINFO	si;
    PROCESS_INFORMATION pi;
	
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );
	
    // Start the child process. 
    BOOL bRetVal = ::CreateProcess( "Exe Path",			  
		(LPSTR)((LPCTSTR)szCommandLine),	  // Command line. 
		NULL,             // Process handle not inheritable. 
		NULL,             // Thread handle not inheritable. 
		FALSE,            // Set handle inheritance to FALSE. 
		0,                // No creation flags. 
		NULL,             // Use parent's environment block. 
		NULL,             // Use parent's starting directory. 
		&si,              // Pointer to STARTUPINFO structure.
		&pi               // Pointer to PROCESS_INFORMATION structure.
	);
Newbie Member
22Oct2007,18:36   #7
dcer's Avatar
like this?

Code:
 CreateProcess("C:\\test.exe",
 (LPSTR)((LPCTSTR)"hello"),
 NULL,
 NULL,
 FALSE,
 0,
 NULL,
 NULL,
 &s,
 &p);
if it is, it doesn't work. =\
Go4Expert Founder
22Oct2007,19:14   #8
shabbir's Avatar
Try running my code and if it does not work you should be exploring the areas where you API work correctly.