Closing MSDOS windows in Delphi

I have written a DOS batch file that runs from my delphi program using the
shell execute statement.Note the application runs hidden since I used the
SW_HIDE command.
Problem: how do I close the MSDOS box or
application when I exit my delphi application. In my batch file I use the
'exit' command which terminates the batch file okay but not the msdos box
where the batch ran from.I found this
out when I shut down windows that the
MSDOS windowed box was still open but
note the batch file had terminated.
Who is Participating?
intheConnect With a Mentor Commented:
yep ive just tested and works fine..
you can use:

WinExec(' /c Some.bat',SW_HIDDEN);
calling with the /c closes the dos window when finshed.
you can also use /c with shellexecute but it saves adding the whole shellapi unit to your uses by just using winexec() ..

Regards Barry
The easiest, non-code way to get the DOS window to close is to use the Windows Explorer to locate the batch file name, right click it to show the Properties, and then check the "Close on Exit" option.

This will work for Windows 95, 98, NT 4.0, and 2000.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.