BAT file

  Gary Wood 10:48 23 Aug 2006

I am trying to write a .bat file to open a program with specific options.

When the .bat file has finished running, I would like it to close it's window. I have tried adding EXIT to the end of the code but it doesn't work. If I put it on the same line as the last bit of my program opening code, I get an error to say the program being opened doesn't recognise some of the code. If I put it on a new line, it appears to be ignored.

How can I make this work?

Also, is there any way to make a batch file run without displaying a window at all?

Thanks in advance,


  mattyc_92 10:53 23 Aug 2006

@echo off
start "<filelocation here>" <commandline switches here>

  Gary Wood 11:22 23 Aug 2006


Thanks for this. However, the @echo only prevents text appearing in the cmd window when the BAT file is run - it doesn't prevent the window from appearing at all.

I'm using the BAT file to open an Access Database using a custom Workgroup so that users have login names and passwords with different access rights.

I have now discovered that the EXIT command does actually work, but it doesn't run until the Access window that the BAT has opened is closed. Is there a way around this?



  mattyc_92 11:24 23 Aug 2006

Do you use the "start" command to run the program?
The "start" command automatically closes the window it is set to open once the window is visible

  Gary Wood 11:31 23 Aug 2006

This is the code I'm using:

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "C:\...\database.mdb" /WRKGRP "C:\...\Security.mdw"

where ... is the full path to the files.

  mattyc_92 11:39 23 Aug 2006

start "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "C:\...\database.mdb" /WRKGRP "C:\...\Security.mdw"

The batch file will be shown only while the program "MSACCESS.EXE" is being launched. Once it is open, the batch file will close

  Gary Wood 13:20 23 Aug 2006

Thanks, mattyc_92.

The code you provided opens Access, but the part which tells Access which Workgroup file to use doesn't appear to be read in the way it was with my version.

With your code Access tries to open the database with the default Workgroup and then gives an error saying I don't have permission to access it.

Any more ideas?


  Coff 14:30 23 Aug 2006

Try the Start command with a space after it and then two quotation marks, so it would be :

Start "" "C:\etc.

If you don't want the command prompt window to appear at all you could create a shortcut to your batch file and run it minimized.

  DieSse 15:42 23 Aug 2006

Run DOS window minimised click here

or even invisibly (but watch the warning).

  mattyc_92 16:49 23 Aug 2006


start "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "C:\...\database.mdb" "/WRKGRP C:\...\Security.mdw"

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Best Black Friday Deals 2017

Black Friday Deals for Designers & Artists: Adobe, Apple, Corel Painter, Microsoft Surface, Wacom &e…

Best Black Friday Apple Deals 2017

Black Friday 2017 : date, sites participants & bonnes affaires