Solved

Batch file not closing after executing

Posted on 2010-08-25
8
647 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 84

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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