Executing a batch file from access

  • Thread starter Thread starter Wesley
  • Start date Start date
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
 
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))
 
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
 
Back
Top