recently i got a hold of a copy of delphi7. having to take a pragmatic approch to learning anything i decided that makeing a front end for "something" would be a good place to start.

so 'using SHELLAPI', fport and a few of the pstools i develped a gui that will list or kill processes locally and remotly, open a remote shell, uses fport to map open ports to apps, will ping a host and start a program remotly. i know....big friggen deal, but for me it's a good way to learn.

now when i use shellexec to run a dos type app it works fine unless it takes lorger than normal for the called app to run. since i redirect the output to a text file and use it as a source for a memo box, if the program hasn't finished i get a "can not open" such and such a file name error. Which has not been a problem on the local network but is accross a vpn where things take a little longer

i use 2 methods.the first will shell out to dos, sleep for 4 seconds then load the returned info to memo1:

begin

Memo1.Lines.SetText('Please Wait While Prosess Info is Gathered.');
Memo1.Refresh ;
ShellExecute(Handle, 'open', PChar('cmd.exe'), PChar('/C PSlist.exe -t \\'+Edit1.Text + ' >Plist.txt'), Nil, SW_HIDE);
Sleep(4000);
Memo1.Lines.LoadFromFile('Plist.txt');
Memo1.SetFocus ;

end;

(the default edit1.text property is set for 127.0.0.1)

the second:

var
SEInfo: TShellExecuteInfo;
ExitCode: DWORD;
ExecuteFile, ParamString, StartInString: string;
begin
ExecuteFile:='cmd.exe ';
ParamString:= '/k PSexec \\'+ Edit1.Text + ' -s cmd';

FillChar(SEInfo, SizeOf(SEInfo), 0);
SEInfo.cbSize := SizeOf(TShellExecuteInfo);
with SEInfo do begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := Application.Handle;
lpFile := PChar(ExecuteFile);
{
ParamString can contain the
application parameters.
}
lpParameters := PChar(ParamString);
{
StartInString specifies the
name of the working directory.
If ommited, the current directory is used.
}
// lpDirectory := PChar(StartInString);
nShow := SW_SHOWNORMAL;
end;
if ShellExecuteEx(@SEInfo) then begin
repeat
Application.ProcessMessages;
GetExitCodeProcess(SEInfo.hProcess, ExitCode);
until (ExitCode <> STILL_ACTIVE) or
Application.Terminated;
ShowMessage('Done!');
end
else ShowMessage('Error starting Program')

end;


waits for the program to complete before returning.

using the first method is there a way to make it wait -or- using the second method is there a way to redirect the output?