How to close DOS window after bat file execution?

Hello - I made the following .bat to open 3 Word doc's I work with everyday:

"C:\Program Files (x86)\Microsoft Office\Office14\Winword.exe" "C:\MyDoc1.docx" "C:\MyDoc2.docx" "C:\MyDoc3.docx"

So I can be as lazy as possible, how can I get the DOS window to close after the doc's have opened?

Thanks
Mark LaGrangeAsked:
Who is Participating?
 
it_saigeDeveloperCommented:
Use start; e.g. -
start "" "C:\Program Files (x86)\Microsoft Office\Office14\Winword.exe" "C:\MyDoc1.docx" "C:\MyDoc2.docx" "C:\MyDoc3.docx"

Open in new window


-saige-
2
 
NVITCommented:
How is the bat being run? Usually it closes automatically.
I haven't confirmed this but if it's run via a shortcut like...
cmd /k your.bat

Open in new window

.. The cmd window will stay open. Changing that to...
cmd /c your.bat

Open in new window

... Will close the window as expected

https://ss64.com/nt/cmd.html
0
 
Dariusz TykaICT Infrastructure Specialist Senior Commented:
You may  try to add 'exit' command at the end of your bat file.
1
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
pgm554Commented:
Yup ,just add exit to the end of the bat file.
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Dariusz Tyka and pgm554,

Exit will not work.  The batch file window stays open because it's waiting for Word to finish - until he closes word, it waits.  UNLESS you use START as it_saige stated.

Exit would only work if the batch file were launched from a pre-existing command prompt.  Double-click the batch file to run and Exit is useless.
0
 
Mark LaGrangeAuthor Commented:
Thanks!
0
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.