ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sending "Enter" command to cmd.exe app... (https://www.excelbanter.com/excel-programming/293985-sending-enter-command-cmd-exe-app.html)

Trevor[_4_]

Sending "Enter" command to cmd.exe app...
 
Hi all,

I have written ( with much help from the message board ) a
macro in excel that opens a .BAT file, runs it, then
continues with the import of a text file. However, when
all is done, there is still a cmd.exe window left open in
the background waiting for "Press any key to
continue...". When any key is pressed within that app,
the app window is closed. Is there a way to send a
command from the excel macro to that app to close it? Any
help is much appreciated.

Thanks,

Trevor

Jim Rech

Sending "Enter" command to cmd.exe app...
 
If you add Exit as the last line of your batch file, does it close the
window?

--
Jim Rech
Excel MVP
"Trevor" wrote in message
...
| Hi all,
|
| I have written ( with much help from the message board ) a
| macro in excel that opens a .BAT file, runs it, then
| continues with the import of a text file. However, when
| all is done, there is still a cmd.exe window left open in
| the background waiting for "Press any key to
| continue...". When any key is pressed within that app,
| the app window is closed. Is there a way to send a
| command from the excel macro to that app to close it? Any
| help is much appreciated.
|
| Thanks,
|
| Trevor



No Name

Sending "Enter" command to cmd.exe app...
 
Mr. Rech,

You inspired a solution. The .BAT file that I was using
is on a network and is used by many others. Their needs
are different and therefore the file required a PAUSE for
user input and then executed the exit command. I simply
created my own .BAT file that does not need to PAUSE for
user input. Thank you for your help. It is much
appreciated.

Thanks,
Trevor

-----Original Message-----
If you add Exit as the last line of your batch file, does

it close the
window?

--
Jim Rech
Excel MVP
"Trevor" wrote in

message
...
| Hi all,
|
| I have written ( with much help from the message

board ) a
| macro in excel that opens a .BAT file, runs it, then
| continues with the import of a text file. However, when
| all is done, there is still a cmd.exe window left open

in
| the background waiting for "Press any key to
| continue...". When any key is pressed within that app,
| the app window is closed. Is there a way to send a
| command from the excel macro to that app to close it?

Any
| help is much appreciated.
|
| Thanks,
|
| Trevor


.


Tom Ogilvy

Sending "Enter" command to cmd.exe app...
 
Shell "cmd.exe /c c:\Myfile.Bat"

=
Regards,
Tom Ogilvy

"Trevor" wrote in message
...
Hi all,

I have written ( with much help from the message board ) a
macro in excel that opens a .BAT file, runs it, then
continues with the import of a text file. However, when
all is done, there is still a cmd.exe window left open in
the background waiting for "Press any key to
continue...". When any key is pressed within that app,
the app window is closed. Is there a way to send a
command from the excel macro to that app to close it? Any
help is much appreciated.

Thanks,

Trevor





All times are GMT +1. The time now is 04:14 PM.

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