Executing a batch file from access

W

Wesley

I am attempting to execute a DOS batch file when my access application
closes. It creates the file, but does not execute the batch file. It will
only execute when I click on the norf.bat file
Here is the code.
************************************************************************
Open "Norf.bat" For Output Access Write As #1
Print #1, "@echo off"
Print #1, "del " & strMDBName
Print #1, "" & strEval & ""
Print #1, "Start " & Chr(34) & MSAccessLocation & "msaccess.exe" & Chr(34) &
Chr(32) & Chr(34) & strMDBPath & strMDBName & Chr(34)
Print #1, "Exit"
Close #1

Dim x As Variant
x = shell(CurDir & "\norf.bat")
Application.Quit
VersionCheck_Exit:
Exit Function
VersionCheck_Error:
End Function
***********************************************************************

Does anyone have a suggestions?

Thanks,
Wesley
 
D

Douglas J. Steele

You use "Norf.bat" when you write it, but CurDir & "\norf.bat" when you try
to run it. Are you sure it's being written to CurDir?

Also, you think you may need double quotes around the file name in your
Shell command, just in case the folder has embedded blanks:

x = shell(Chr(34) & CurDir & "\norf.bat" & Chr(34))
 
W

Wesley

Yes, It is being written to the "Curdir", because that's where when I
double-click norf.bat, it then executes. I just tried your suggestion, and
norf.bat still does not automatically execute. I must double-click it. I do
need it to execute without my intervention.

thanks
 

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