BAT file

  Gary Wood 10:48 23 Aug 06
Locked

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,

Gary

  mattyc_92 10:53 23 Aug 06

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

  Gary Wood 11:22 23 Aug 06

mattyc_92,

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?

Thanks,

Gary

  mattyc_92 11:24 23 Aug 06

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 06

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 06

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 06

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?

Gary

  Coff 14:30 23 Aug 06

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 06

Run DOS window minimised click here

or even invisibly (but watch the warning).

  mattyc_92 16:49 23 Aug 06

Try....

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.

How to get Windows 10 for free | How to install Windows 10: There is still a way to avoid paying…

1995-2015: How technology has changed the world in 20 years

Hands-on with the Star Wars fighting drones you can fly yourself

15 macOS Sierra tips | How to use macOS Sierra: Secret tricks and best new features in Apple's new…