General discussion

Locked

XP Batch File will not exit

By haycoconsulting ·
I have written a short batch file to copy the most current version of a database from a common "library" drive (L:) to the users "user" drive (G:) then open the file in MS Access. The code works fine except it never sees the "exit" command so the cmd prompt window never closes.

I am thinking it has to do with the 'environment'. I have tried several variations of 'setlocal' and 'endlocal' but haven't made it work so I could be wrong about that.

Here is the entire batch file (running fromthe g:\ALDS directory - that is a requirement)


1) xcopy L:\ALDS\Support\ALDSEntry.mdb G:\ALDS\ALDSEntry.mdb /Q /K /Y /D /Z
2) "c:\Program Files\Microsoft Office\Office\MSACCESS.EXE" G:\ALDS\ALDSEntry.mdb
3) exit

(I have inserted line numbers above for clarity. They do not exist in the batch file.)

I am running XP but my client is running Win2000 Professional. So far everthing has been compatible so if it doesnt work I ***-u-me it won't work there.

Anybody know how to make the thing close?

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

XP Batch File will not exit

by Joseph Moore In reply to XP Batch File will not ex ...

Does your Access database close, or does it say open?
The reason I ask is that if the database stays open, then the BAT file never goes down to the 3rd line. When a BAT file opens an application, it stays on that line until the application closes(which sends a signal to Windows; the BAT file picks up this signal and continues onto the next line in the BAT).
So, if you are copying files, then opening Access to process the files, you need to have Access close down, so the BAT file will continue and process the last line.
You could write a Macro that opens the Access database, runs whatever process Access needs to do, then closes itself down. That would work for the BAT file to continue.

hope this helps

Collapse -

XP Batch File will not exit

by haycoconsulting In reply to XP Batch File will not ex ...

Thanks for the tip but in this case I had to do the copy prior to opening the DB (to ensure the latest version of the Entry DB) and leave the DB open.

Collapse -

XP Batch File will not exit

by Don Christner In reply to XP Batch File will not ex ...

In order to return to the batch file after going to Access, you'll need to Call the third line. Call tells it to run the executable and then return to the batch file. Otherwise, once it leaves the batch file it will not return.

Don

Collapse -

XP Batch File will not exit

by haycoconsulting In reply to XP Batch File will not ex ...

Tried it but couldn't make it work like I needed...Thanks for you time anyway.

Collapse -

XP Batch File will not exit

by BeerMonster In reply to XP Batch File will not ex ...

Hi,
actually a call command means to 'call' the application, then wait for it to finish - exactly the problem you are having now. Make your second line

START "startapp" "c:\Program Files\Microsoft Office\Office\MSACCESS.EXE" G:\ALDS\ALDSEntry.mdb

-all one line obviously. The start command tells the batch file to start the app and then carry on with the next line. The "startapp" part is to get round a quirk of the start command - it views the first string in quotes as a window title,so this stops it confusing your msaccess string (which is in quotes) and trying to make that the window title. Hope this helps...

Collapse -

XP Batch File will not exit

by haycoconsulting In reply to XP Batch File will not ex ...

Thanks BeerMonster - I owe you a beer. But since I doubt you'll be in Lubbock today, here....have 250 points. Works like a charm and does exactly what I want. Thanks.

Collapse -

XP Batch File will not exit

by haycoconsulting In reply to XP Batch File will not ex ...

This question was closed by the author

Back to Windows Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums