• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 652
  • Last Modified:

Batch file not closing after executing

Hello

I am trying to run a simple batch code but it is not closing after executing.

Have tried the following, but none of them close

'------------------------------------------
COPY C:\NATIVGRP\NATIV14.accdb C:\LAST\NATIV14.accdb /y
C:\NATIVGRP\NATIV14.accdb
'------------------------------------------
OR
'------------------------------------------
COPY C:\NATIVGRP\NATIV14.accdb C:\LAST\NATIV14.accdb /y
C:\NATIVGRP\NATIV14.accdb
EXIT
'------------------------------------------
OR
'------------------------------------------
COPY C:\NATIVGRP\NATIV14.accdb C:\LAST\NATIV14.accdb /y
CALL "C:\NATIVGRP\NATIV14.accdb"
EXIT


Thanks.
0
gabi456
Asked:
gabi456
3 Solutions
 
dirkvdoCommented:
How big is the nativ14.accdb file ?

Try putting a PAUSE command between the first and the second line, lauch the batchfile and wait long enough before you press enter at the pause (to allow the copy to finish, as I believe that is the problem)and see if it exits correctly. If it does, you should insert a loop that checks the existence of the copied file before running it.

Regards,

Dirk
0
 
oBdACommented:
Don't use "call" to run an external program (or start a file); "call" is only necessary to run other batch files from a batch file.
Instead, use "start" to run the program and let the batch continue:
start "" "C:\NATIVGRP\NATIV14.accdb"
(INCLUDING the empty pair of quotes directly after "start"!)
0
 
gabi456Author Commented:
Thanks for replying.

It actually does finishing copying only the command promt window does not close.
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
Steve KnightIT ConsultancyCommented:
Use

START "" "C:\NATIVGRP\NATIV14.accdb"

The START command tells it to start the database and then close the window.  If you just execute the accdb it wil start potentially but leave the batch waiting to go to the next line.  The first "" is the window title and necessary if you have any spaces in the path of the command you run -- in your case you could lose the "" if you also remove the "" around hte db path
0
 
Steve KnightIT ConsultancyCommented:
snap!
0
 
DhopeCommented:
Try replacing CALL with START

You shouldn't need to put exit at the end
Maybe also save it as a .CMD rather than .BAT, though that's unlikely to make a difference.

0
 
gabi456Author Commented:
Thanks man.
0
 
Steve KnightIT ConsultancyCommented:
I suggest in future you look towards the "A" grade button if possible.  We are only rewarded here by points and grades.

Steve
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now