CreateProcess help...

dcer's Avatar, Join Date: Oct 2007
Newbie Member
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?
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Second parameter is the command line you want to pass to the exe.
0
dcer's Avatar, Join Date: Oct 2007
Newbie Member
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.."
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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.
0
dcer's Avatar, Join Date: Oct 2007
Newbie Member
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);
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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.
	);
0
dcer's Avatar, Join Date: Oct 2007
Newbie Member
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. =\
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Try running my code and if it does not work you should be exploring the areas where you API work correctly.