Solved

Batch file not closing after executing

Posted on 2010-08-25
8
649 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 85

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
Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
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 modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to dynamically set the form action using jQuery.

623 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