Solved

Batch file not closing after executing

Posted on 2010-08-25
8
648 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 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

752 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