Solved

Batch file not closing after executing

Posted on 2010-08-25
8
646 Views
Last Modified: 2013-11-09
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
Comment
Question by:gabi456
8 Comments
 
LVL 2

Expert Comment

by:dirkvdo
ID: 33519567
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
 
LVL 83

Assisted Solution

by:oBdA
oBdA earned 83 total points
ID: 33519647
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
 

Author Comment

by:gabi456
ID: 33519656
Thanks for replying.

It actually does finishing copying only the command promt window does not close.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 43

Accepted Solution

by:
Steve Knight earned 84 total points
ID: 33519661
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33519664
snap!
0
 
LVL 5

Assisted Solution

by:Dhope
Dhope earned 83 total points
ID: 33519676
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
 

Author Closing Comment

by:gabi456
ID: 33519713
Thanks man.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33521109
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question