dkmoreland
Registered User.
- Local time
- Today, 14:30
- Joined
- Dec 6, 2017
- Messages
- 129
I am trying to implement the Front End AutoUpdating Utility that has been so graciously made available by Bob Larson. I am trying to run it on a network with a fairly strict group policy. Every time the code gets to the point of running the batch file, it stops. The batch file is created and just sits there. When I try to run it manually, I get a group policy error.
I'm a contractor here so I have minimal access and authority. I asked the IT folks - they did open it up so this batch file will run if it is in the %TEMP% folder on the user's local drive.
So my question is - where do I modify the code below to accommodate this? I can see where the path to the Testfile is set but where does CurrentProject.Path come from?
Or, do I need to modify this code (below) that actually makes the call to the function shown above?
Thanks in advance for any and all input.
I'm a contractor here so I have minimal access and authority. I asked the IT folks - they did open it up so this batch file will run if it is in the %TEMP% folder on the user's local drive.
So my question is - where do I modify the code below to accommodate this? I can see where the path to the Testfile is set but where does CurrentProject.Path come from?
Code:
Option Compare Database
' global variable for path to original database location
Public g_strFilePath As String
' global variable for path to database to copy from
Public g_strCopyLocation As String
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
' 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 2000"
Print #1, ""
Print #1, "Del """ & strKillFile & """"
Print #1, ""
Print #1, "ECHO Copying new file"
Print #1, "Copy /Y """ & strReplFile & """ """ & strKillFile & """"
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
Shell TestFile
'closes the current version and runs the batch file
DoCmd.Quit
End Sub
Or, do I need to modify this code (below) that actually makes the call to the function shown above?
Code:
Private Sub Form_Load()
Dim strFEMaster As String
Dim strFE As String
Dim strMasterLocation As String
Dim strFilePath As String
' looks up the version of the front-end as listed in the backend
strFEMaster = DLookup("fe_version_number", "tbl-version_fe_master")
' looks up the version of the front-end on the front-end
strFE = DLookup("fe_version_number", "tbl-fe_version")
' looks up the location of the front-end master file
strMasterLocation = DLookup("s_masterlocation", "tbl-version_master_location")
' checks for the existence of an updating batch file and deletes it if it exists
strFilePath = CurrentProject.Path & "\UpdateDbFE.cmd"
If Dir(strFilePath) <> "" Then
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile (strFilePath)
Set fs = Nothing
End If
' if the current database opened is the master then it bypasses the check.
If CurrentProject.Path = strMasterLocation Then
Exit Sub
Else
' if the version numbers do not match and it is not the master that is opened,
' the database will do the update process
If strFE <> strFEMaster Then
MsgBox "Your program is not the latest version." & vbCrLf & _
"The front-end needs to be updated. The program will " & vbCrLf & _
"now close and then should reopen automatically.", vbCritical, "VERSION NEEDS UPDATING"
' sets the global variable for the path/name of the current database
g_strFilePath = CurrentProject.Path & "\" & CurrentProject.Name
' sets the global variable for the path/name of the database to copy
g_strCopyLocation = strMasterLocation
' calls the UpdateFrontEnd module
UpdateFrontEnd
End If
End If
End Sub
Thanks in advance for any and all input.