I would like to execute an application with parameters without a gui window, then auto end process gracefully in 2minutes.
This is how I use the code:
procedure ExecNoWait(Filename: string);
var
bchExec: array[0..1024] of char;
pchEXEC: Pchar;
si: TStartupInfo;
pi: TProcessInformation;
begin
pchExec := @bchExec;
StrPCopy(pchExec,Filename);
FillChar(si,sizeof(si),0);
FillChar(pi,sizeof(pi),0);
si.dwFlags:=STARTF_USESHOWWINDOW;
si.wShowWindow:=SW_HIDE;
si.cb := sizeof(si);
CreateProcess(Nil,pchExec,Nil,Nil,false,CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, Nil,Nil,si,pi);
end;
ExecNoWait(TheExeFilePath + '\ThisExe.exe -runnow'); //NON-GUI App
But I want to auto end or auto close the ThisExe.exe gracefully in 2minutes time.
How do we solved this?
thanks