I have the following code, where EXE is a valid filename for an executable on my system:
Code: Select all
var
P: IProcess;
Running, NeedRestart: Boolean;
begin
P := Process(EXE);
Running := P.IsStillRunning;
NeedRestart := True; // just for testing
if not Running or NeedRestart then
begin
if Running then P.Close;
NewProcess(Path);
end;
end;
Regards, Claes