Help to windows cmd. lazarus / 12-Debugger ---------------------------------------------------------------------- nocuttree · 2014-09-22 11:01 Hello all, I am using this code Code: [Select]if ShellExecute(0,nil, PChar('cmd'),PChar('/c mybatch.bat'),nil,1) =0 then; to run a bacth file. I want to hide this windows cmd and have a command to wait this windows cmd close. Thanks to all! ---------------------------------------------------------------------- Mike.Cornflake · 2014-09-22 11:15 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 method http://wiki.lazarus.freepascal.org/Executing_External_Programs Just 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]; ---------------------------------------------------------------------- nocuttree · 2014-09-25 11:51 Quote from: Mike.Cornflake on September 22, 2014, 01:15:31 pmI 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 method http://wiki.lazarus.freepascal.org/Executing_External_Programs Just 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]; Thanks you!