if ShellExecute(0,nil, PChar('cmd'),PChar('/c mybatch.bat'),nil,1) =0 then;
AProcess.Options := AProcess.Options + [poWaitOnExit, poNoConsole];
I don't think you can wait with ShellExecute. I think it fires off the command and immediately returns to code, letting the command run in another process.You can TProcess. It's cross platform and the preferred methodhttp://wiki.lazarus.freepascal.org/Executing_External_ProgramsJust ensure you have poWaitOnExit in the options. Err, and there's another po for Hide - ahh, poNoConsole...Extending the Simple Example in the wiki change this line...Code: [Select] AProcess.Options := AProcess.Options + [poWaitOnExit, poNoConsole];