Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

End a batch file

Posted on 2005-03-25
14
Medium Priority
?
659 Views
Last Modified: 2012-05-05
Hello Experts,
I an typically making changes to the .MDB weekly.
I want those changes to go into effect the next time a user fires up my .MDE, so I compile it to the network, and have the users execute a batch file that copies the new .MDE to their local work stations, then fires up the latest version of the .MDE.

The problem is, my batch file won't end until the user terminates the .MDE.

Is there a way to force the batch file to end and close while the .MDE is still running?

here is the batch file:


*********

copy "O:\MyDir\MyOtherDir\MyProgram.mde" "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde" /y
"C:\Program Files\MyDir\MyOtherDir\MyProgram.mde"

*********

Thanks,
David
0
Comment
Question by:DavidWare
  • 6
  • 5
  • 3
14 Comments
 
LVL 97

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 200 total points
ID: 13634935
I'm a little confused about what you are doing, but try running the batch file with the "START" command.  



copy "O:\MyDir\MyOtherDir\MyProgram.mde" "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde" /y
start "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde"
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 13635437
It won't quit because it should not.

Here's another method for this purpose.

Create a shortcut to run the copy and launch process.
Choose tab Program.
Set Command line to: "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde"
Set Batch file to: <path and name of your batch file>
Mark Close when finished/terminated.

Reduce the batch file to:

@echo off
echo Copying current program file ...
copy "O:\MyDir\MyOtherDir\MyProgram.mde" "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde"

Now, let the users run the shortcut.

/gustav
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13635446
Try START first - I'm fairly certain it will work.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:DavidWare
ID: 13657935
Hello leew and Cactus_Data
leew,
start does end the first command prompt session, but it opens another one in the C:\Program Files\MyDir\MyOtherDir directory
(My cursor is:  C:\Program Files\MyDir\MyOtherDir>_  )


gustav,
I think you are suggesting that I have 2 seperate shortcuts:
1) one to copy the .MDE over from the network to the local drive, and
2) a completely seperate shortcut for executing the .MDE.

Am I right?

If so. that is not my goal.

I want the users to

1) double-click the icon and have my batch file copy the .MDE over from the network to the local drive AND EXECUTE THE .MDE all in the same batch file.

Only one shortcut, please.

The question that will get the points is "Is there a way to force the batch file to end and close while the .MDE is still running?"

Thanks,
David
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13658629
Can you post the batch file.  Start should work.
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 13660283
> I think you are suggesting that I have 2 seperate shortcuts

I wonder why? This is what I wrote:

Create a shortcut to run the copy and launch process.

We use this method at those of our clients with POS applications; these just have to work.
We even put the shortcut in the Start folder.

/gustav
0
 

Author Comment

by:DavidWare
ID: 13663937
Hello leew and gustav,
First, thanks again for the followup.  I intend to increase the points and split them.

leew,
the batch fril is just as you posted:

copy "O:\MyDir\MyOtherDir\MyProgram.mde" "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde" /y
start "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde"

The first command window opens and copies the .MDE from the network to the local drive, then closes.
But then another command window opens with the following text in the blue bar at the top:
          C:\Program Files\MyDir\MyOtherDir\MyProgram.mde

and the following text in the command window:

          Microsoft Windows 2000 [Version 5.00.2195]
          (C) Copyright 1985-2000 Microsoft Corp

          O:\MyDir\MyOtherDir>

and the cursor blinking to the right of the O:\MyDir\MyOtherDir>

*** my mistake in the previous post when I wrote: "(My cursor is:  C:\Program Files\MyDir\MyOtherDir>_  )"
Actually My cursor is:  O:\MyDir\MyOtherDir> ***


gustav,
Forgive me, but I am not understanding the instructions.
you said:
Create a shortcut to run the copy and launch process.
Choose tab Program.
Set Command line to: "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde"
Set Batch file to: <path and name of your batch file>
Mark Close when finished/terminated.


First, when I create a shortcut, there are no Tabs, simply a textbox for the full file name, and a Browse button.  Then a textbox for the name.
So, I create a shortcut, then (once it's created), I open it's properties.
Now I have Tabs, but none called "Program".
So, selecting the "Shortcut" tab, I enter the full file name of the program, as you wrote:
"Set Command line to: 'C:\Program Files\MyDir\MyOtherDir\MyProgram.mde'"
Now, your instruction: "Set Batch file to: <path and name of your batch file>" is completely confusing.
There is no place to reference a Batch File in the shortcut properties.  
There is a place to reference the "Start In" directory, but that will not accept a full file name.
The error says that "The Folder... is not valid".  This "Start In" is looking for a Directory only.

So, as you can see, I am trying to follow your instructions, but your syntax seems to be non sequitur.

David
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 400 total points
ID: 13664175
You are right, sorry.
What you need is to create a shortcut (a PIF file) to a MS-DOS program - then you'll have the necessary tabs and fields.

Create one for, say, command.com. Save it.
Now choose properties and adjust as I wrote.

/gustav
0
 

Author Comment

by:DavidWare
ID: 13665457
Hello gustav,
Well, we're getting closer.
I created the .PIF shortcut, and edited it as follows:

Program Tab
Cmd line: "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde"
Working: "C:\Program Files\MyDir\MyOtherDir"
Batch File: "O:\MyDir\MyOtherDir\UpdateAndRunMagProgram.bat

So when I run it, the error tells me:

C:\DOCUME~1\DavidWare\Desktop\MyProgram.pif
C:\Program Files\MyDir\MyOtherDir\MyProgram.mde.
The file is not a valid MS-DOS program file.
MS-DOS program files must end with the extension .EXE, .COM, or .BAT.

So I tried putting just the batch file in as the CmdLine and the Command window opens for a flash but closes w/o copying or running the .MDE.
I tried substituting "O:\MyDir\MyOtherDir" in as the "Working" directory, but when there is an .MDE file listed as the "Cmd line" file, it fails with the above copied error.

It looks like it wants the .BAT file in as the "Cmd line" but that does nothing besides flash the Dos window at me.

What am I doing wrong?

Thanks,
David
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 13665540
You need the full command line, like:

Cmd line: "C:\Program Files\Microsoft Office\Access\MsAccess.exe" "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde"

/gustav
0
 

Author Comment

by:DavidWare
ID: 13666088
Hello gustav,
Thanks for replying.

The shortcut opens the local copy of the .MDE, but it's last week's version.
This week's version of the program is not being copied from the network first.

Cmd line:  "C:\Program Files\Microsoft Office\Office\MSAccess.exe" "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde"
Working:   "C:\Program Files\MyDir\MyOtherDir"
Batch File:  O:\MyDir\MyOtherDir\UpdateAndRunMyProgram.bat

UpdateAndRunMyProgram.bat contains the command:
copy "O:\MyDir\MyOtherDir\MyProgram.mde" "C:\Program Files\MyDir\MyOtherDir\MyProgram.mde" /y


In other words, the shortcut doesn't copy the new version of the file (from the network to the local drive) before executing the local copy.
I assume that the shortcut is executing the local copy first, then is unable to overwrite the locan .MDE, because it's in use.
(As a result, I assume, the Command window stays open while the local copy is running - which is the reason for this question in the first place).

Any ideas on how to get the .BAT file to execute first (copying over this week's version of the .MDE), and then execute the .MDE?

Thanks,
David
0
 

Author Comment

by:DavidWare
ID: 13666274
Tried creating 2 .BAT files - one to copy the file and one to execute it.

Cmd line:  O:\MyDir\MyOtherDir\UpdateMyProgram.bat
Working:   O:\MyDir\MyOtherDir
Batch File:  O:\MyDir\MyOtherDir\RunMyProgram.bat

And the Command window flashes, but the file is not copied over, and the .MDE does not run.

I'm confident of the syntax.  Also tried it with quotes.

Then I tried JUST copying the file over:

Cmd line:  O:\MyDir\MyOtherDir\UpdateMyProgram.bat
Working:   O:\MyDir\MyOtherDir
Batch File:

And the same thing (a milli-second flash of the Command window) occurs.

By the way, if I execute O:\MyDir\MyOtherDir\UpdateMyProgram.bat from Windows Explorer, the Command window stays open for a full 2 secongs, and the file is copied to the local drive.  Executing the shortcut that calls the same .BAT file fails.

Any ideas?

Thanks,
David
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 13669637
> the shortcut doesn't copy the new version of the file (from the network to the local drive) before executing the local copy.

That's strange. It works nicely at our clients.
The batch file should run initially - that's the purpose of it also according to the on-line help.

/gustav
0
 

Author Comment

by:DavidWare
ID: 13740999
Well, I didn't solve it, but I'm convinced that I'm doing something wrong, and I will continue to work on it.
Thanks to both
David
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

580 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