Opening A bat File From Access 2003

A

Arturo

I have a long process that takes place when one of my Access databases opens
up. One of the last things I do in the process is to delete files out of a
directory. I have my reasons for doing it this way, but as this file closes,
it opens another Access database.

When this database opens, it opens a form. I tell the form to close after it
opens. In the OnClose event I need it to open the bat file (sequenceRun.bat)
in the folder C:\abc\def\. This bat file deletes all the Access files in that
folder.

However, I can’t get the file to run. Can anyone help?

Thanks.
 
G

Gina Whipp

Arturo,

Is there a reason you choose to run a bat file instead of using Kill to
delete the files?

As to your question what is the code you are using to run the bat file? I
see you provided an example of the path BUT does the actuall path contain
any spaces?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
A

Arturo

Yes there are spaces. I use the bat file because it is created by a script in
the first file. I am trying to open it with this:

Dim RunSequence As String
RunSequence = "C:\a bc\def\sequenceRun.bat"
DoCmd.SetWarnings False
Application.FollowHyperlink RunSequence

And this:

Dim RunSequence As String
RunSequence = "C:\a bc\def\sequenceRun.bat"

Dim retValue As Double
retValue = Shell(RunSequence)
 
G

Gina Whipp

Arturo,

I seem to remember spaces being an issue... To test that theory you can
place the file in a folder and change the path in your code. If it deletes
then you might try..

Shell "cmd /k ""C:\a bc\def\sequenceRun.bat""", vbNormalFocus

and remove the RunSequence statement altogether.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
A

Arturo

Are you saying I should just use the line of code you have here? If so, it
didn't work for me.

Thanks.
 
A

Arturo

Gina, I am using the following code:

Kill "C:\a bc\def\*.mdb"

This does delete all the mdb files in that folder. However, if there are no
mdb files in the folder, it bombs out on that command. How do I keep it going
if the folder has no mdb files?

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top