End a batch file

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
DavidWareAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee W, MVPTechnology and Business Process AdvisorCommented:
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
Gustav BrockCIOCommented:
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
Lee W, MVPTechnology and Business Process AdvisorCommented:
Try START first - I'm fairly certain it will work.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

DavidWareAuthor Commented:
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
Lee W, MVPTechnology and Business Process AdvisorCommented:
Can you post the batch file.  Start should work.
0
Gustav BrockCIOCommented:
> 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
DavidWareAuthor Commented:
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
Gustav BrockCIOCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DavidWareAuthor Commented:
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
Gustav BrockCIOCommented:
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
DavidWareAuthor Commented:
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
DavidWareAuthor Commented:
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
Gustav BrockCIOCommented:
> 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
DavidWareAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.