ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Closing DOS window after shell command (https://www.excelbanter.com/excel-programming/287406-closing-dos-window-after-shell-command.html)

Garry Boswell

Closing DOS window after shell command
 
I have a macro that runs the shell command to run a DOS
batchfile. At the end of the batchfile, the DOS window
will not close, even though the last line of the file is
EXIT. If I run the batchfile from a DOS window to begin
with, then the DOS window closes.

I am running Excel 2000 under Windows 98.

How can I close the DOS window from the macro?

TIA
Garry

jaf

Closing DOS window after shell command
 
Hi Garry,
RetVal = Shell(Environ$("comspec") & " /c yourfile.bat",vbNormalFocus)

The /c will kill the window. Use /k to keep it open.


--
John
johnf 202 at hotmail dot com


"Garry Boswell" wrote in message
...
| I have a macro that runs the shell command to run a DOS
| batchfile. At the end of the batchfile, the DOS window
| will not close, even though the last line of the file is
| EXIT. If I run the batchfile from a DOS window to begin
| with, then the DOS window closes.
|
| I am running Excel 2000 under Windows 98.
|
| How can I close the DOS window from the macro?
|
| TIA
| Garry




All times are GMT +1. The time now is 05:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com