NBilov 0 Posted May 8, 2023 When I run a cmd file in delphi by shellexecute method it raises black cmd window during execution. How can I execute it in ordinary vcl windows application invisibly without this window. Share this post Link to post
David Heffernan 2345 Posted May 8, 2023 What does "run a cmd file" mean? My guess is that you need to use CreateProcess with the CREATE_NO_WINDOW flag. Share this post Link to post
PeterBelow 238 Posted May 8, 2023 35 minutes ago, NBilov said: When I run a cmd file in delphi by shellexecute method it raises black cmd window during execution. How can I execute it in ordinary vcl windows application invisibly without this window. Try to pass SW_HIDE as the last parameter. Share this post Link to post
David Heffernan 2345 Posted May 8, 2023 1 hour ago, PeterBelow said: Try to pass SW_HIDE as the last parameter. This relies on the other process to respond to that flag, and they often won't. And certainly they won't of they are console apps. It's a very common mistake to try to run a console app with ShellExecuteEx which is designed to execute shell verbs not to create processes. Share this post Link to post
NBilov 0 Posted May 8, 2023 In this cmd files I almost never use any console programs. Only program with datamodule , which executes a task and closes. Or batch scripts - mostly file operations and git commands Share this post Link to post
stijnsanders 35 Posted May 8, 2023 If you need to capture and process the output of the cmd, I would even advise to use CreateProcess with STARTF_USESTDHANDLES. I have an example here, but it's a bit of a confusing sample because the reading of the pipes happens in the DoCommand procedure, I should take some time to write a cleaner example... Share this post Link to post
Patrick PREMARTIN 69 Posted May 9, 2023 Perhaps this project will help you : https://github.com/TurboPack/DOSCommand Share this post Link to post