Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

This is tricky depending on deployment scenario. You have a few options to make it only run once, in this example I created an "Update_Log.txt" on the central server which each computer writes to when it is updated and checks for the update log before presenting message again. Now when I deploy an update I change the "Revision #" and the "UpdateMsg" and it is deploy to each computer. The MsgBox is displayed once and I can also track who has received the update.

Main Sub:

Public blnFound As Boolean
Public UpdateRev As Variant
Public Sub UpdateMsg()

Call UpdateLogCheck ' Check and/or create Update_Log.txt
blnFound = False ' Always start false
UpdateRev = "Updated:1" & (Environ$("Username")) 'Increment with each Update
Call SearchTextFile(UpdateRev)

If Not blnFound = "True" Then
    Call Update_Msg
    Call IncrementUpdateLog(UpdateRev)
End If
End Sub

CreateUpdateLog Module:

Public Sub UpdateLogCheck()
Dim UpdateFile As Variant
UpdateFile = "\\server\update_log.txt"
Set fs = CreateObject("Scripting.FileSystemObject")
If Dir(UpdateFile, vbDirectory) = vbNullString Then
    Set a = fs.CreateTextFile(UpdateFile, False)
End If
End Sub

Search Update Log Module:

Public Sub SearchTextFile(strSearch)
     strFileName = "\\server\update_log.txt"
     ' Const strSearch = "Updated:1"
     Dim strLine As String
     Dim f As Integer
     Dim lngLine As Long
     f = FreeFile
     Open strFileName For Input As #f
     Do While Not EOF(f)
         lngLine = lngLine + 1
         Line Input #f, strLine
         If InStr(1, strLine, strSearch, vbBinaryCompare) > 0 Then
             blnFound = True
             Exit Do
         End If
     Close #f
End Sub

The UpdateMsg Module:

Public Sub Update_Msg()

Dim line1 As Variant
Dim line2 As Variant
Dim line3 As Variant
Dim line4 As Variant
Dim line5 As Variant
Dim line6 As Variant
Dim line7 As Variant
Dim line8 As Variant
Dim line9 As Variant

line1 = "This is the 'New Revision' Message, it should only appear once when there is a new revision"
line2 = "This Revision focused on this new delivery system for Revision Updates"

    MsgBox line1 & vbCrLf & vbCrLf & _
           line2 & vbCrLf & vbCrLf & _
           line3 & vbCrLf & vbCrLf & _
           line4 & vbCrLf & vbCrLf & _
           line5 & vbCrLf & vbCrLf & _
           line6 & vbCrLf & vbCrLf & _
           line7 & vbCrLf & vbCrLf & _
           line8 & vbCrLf & vbCrLf & _
           line9 & vbCrLf & vbCrLf

End Sub

Increment/Update Log File:

Public Sub IncrementUpdateLog(UpdateRev)

Dim UpdateFile As Variant
UpdateFile = "\\server\update_log.txt"
Open UpdateFile For Append As #1
Write #1, UpdateRev
Close #1

End Sub
  • No labels