Solved

How to close dos-window after shellexecute?

Posted on 1997-04-16
3
449 Views
Last Modified: 2010-04-04
If I do a shellexecute :

(You have to have shellapi in your uses clause,
in the tst.bat you can do something like dir /b,
handle is an integer)
 ShellExecute(handle,NIL,'tst.bat',NIL,'c:\tmp',SW_NORMAL);

I get a window which says "Finished tst.bat"
If I do:

ShellExecute(handle,NIL,'tst.bat',NIL,'c:\tmp',SW_HIDE);

I do not get that window, but it remains in memory.
(You can see this from the list of winoldap's in the process
list you get from doing ctrl-alt-del in win95)

The question is: How do I close that window?
0
Comment
Question by:jsirag
3 Comments
 
LVL 1

Accepted Solution

by:
sleach earned 50 total points
ID: 1335409
The answer is AMAZINGLY simple.

1) Find tst.bat in Windows Explorer.
2) Right click on tst.bat
3) From the popup menu, click Properties.
4) In the propertie sheet, click on the Program tab.
5) Check the box that says "Close on Exit."
6) click OK.

The window will now close automatically after it finishes its work.
Be sure to distribute the modified batch file with your app.
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1335410
There's an API method to do this, which might be more suitable in the generic-code sense.
0
 

Author Comment

by:jsirag
ID: 1335411
Actually, the API method is what I was most interested in. Of
course, the answer works fine, but it is rather time-consuming
in a large company (to set all the dos-executable to auto-finish
for let's say several hunderd people). Furthermore I would like
to do the work in the program, not in windows.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

29 Experts available now in Live!

Get 1:1 Help Now