Shell Batch File Not Running in Access

R

Red Rider

I'm trying to get the AutoUpdate Front End program to run. This
program will automatically update each users FE if the version #'s
don't match. Here's the last of the code where the copying takes
place. It creates the UpdateDbFE.cmd OK but does not execute the
Shell TestFile command. If I just double-click this file
(UpdateDbFE.cmd) outside of Access it runs OK, executing all the
commands. Here's the code:

Public Sub UpdateFrontEnd()

Dim strCmdBatch As String
Dim notNotebook As Object
Dim FSys As Object
Dim TestFile As String
Dim strKillFile As String
Dim strReplFile As String
Dim strRestart As String

' added 12/2/08 to also copy PDF Help file on update
Dim strKillHelpFile As String
Dim strReplHelpFile As String
' sets the file name and location for the file to delete
strKillHelpFile = g_strHelpFilePath
' sets the file name and location for the file to copy
strReplHelpFile = g_strCopyLocation & "\Grid Contracts Help File.PDF"

' sets the file name and location for the file to delete
strKillFile = g_strFilePath
' sets the file name and location for the file to copy
strReplFile = g_strCopyLocation & "\" & CurrentProject.Name
' sets the file name of the batch file to create
TestFile = CurrentProject.Path & "\UpdateDbFE.cmd"
' sets the restart file name
strRestart = """" & strKillFile & """"

' creates the batch file
Open TestFile For Output As #1
Print #1, "Echo Off"
Print #1, "ECHO Deleting old file"
Print #1, ""
Print #1, "ping 1.1.1.1 -n 1 -w 9000"
Print #1, ""
Print #1, "Del """ & strKillFile & """"
Print #1, ""
Print #1, "ECHO Copying new file"
Print #1, "Copy /Y """ & strReplFile & """ """ & strKillFile & """"
Print #1, "ECHO Copying new Help file"
Print #1, "Copy /Y """ & strReplHelpFile & """ """ & strKillHelpFile &
""""
Print #1, ""
Print #1, "CLICK ANY KEY TO RESTART THE ACCESS PROGRAM"
Print #1, "START /I " & """MSAccess.exe"" " & strRestart
Close #1
' Exit Sub

' runs the batch file
MsgBox "Click OK to Start Batch" ' I see this message

Shell TestFile

MsgBox "Batch File Started" ' I don't see this message

'closes the current version and runs the batch file
DoCmd.Quit

End Sub

Any help will be appreciated.
 
D

Douglas J. Steele

Try changing

Shell TestFile

to

Shell Environ("ComSpec") & " /c " & TestFile
 
R

Red Rider

Try changing

Shell TestFile

to

Shell Environ("ComSpec") & " /c " & TestFile

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)

















- Show quoted text -

I'll try that command. Thanks.

What I did to get it working was:

Shell """C:\Grid Contracts\Grid Contracts Help File.PDF"""

The triple quotes got it working.
 

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