Const UpdateName = "Payroll Africa"                                  'Required
Const UpdateShortName = "Payroll Africa"                                    'Required
Const UpdateVersion = "1.27.001"                                                 'Required
Const UpdateUpdateURL = "http://www.donkerhoekdata.co.za/downloads/dls1.udi"  'Optional - enables "Check for Web Updates"

                                         'Required
Const UpdateAllowSkipOnceFound = "True"                                     'Optional - defaults to false
Const UpdateAllowSearch = "True"                                            'Required
Const UpdateSearchCriteria = "*\DLS1.exe"                                 'Required
Const UpdateDefaultFolder = "C:\AFRICA"                             'Required

'Const WizardText0_2 = "This is the update wizard of %Name%"                'Optional - allows you to override default
                                                                            'text. This overrides page 0, item 2.

':End                                                                       'Required



'Required: Function Main
'The wizard will pass the install path (as a string), but you can ignore it - check that it's not a Network drive first!
'Remember! In VBScript, you can't declare types.

Function Main(strInstallPath)
   UIStatusUpdate PathCompactPathEx("Installing to " & strInstallPath & "...", 38)  '38 is the number of "w"s the space holds
   InstallAttributesRemove(PathAddBackslash(strInstallPath) & "*.*")
   InstallBackupRecur(PathAddBackslash(strInstallPath) & "DLS1.EXE")
   blnRetVal = InstallInstallRecur("*.*", strInstallPath)
   InstallAttributesRemove PathAddBackslash(strInstallPath) & "*.*"	
   if blnRetVal = false then
	Msgbox "Update failed. Please close the Payroll Africa program and run this wizard again.", vbCritical , "Error"
	exit function
   end if	
	
   strPath = InstallFindInSubDirectory(strInstallPath, "DLS1*.EXE")
   if strPath <> "false" then
   UIStatusUpdate PathCompactPathEx("Installing to " & strPath & "...", 38)  '38 is the number of "w"s the space holds
   InstallAttributesRemove PathAddBackslash(strPath) & "*.*"
   InstallBackupRecur PathAddBackslash(strPath) & "DLS1.EXE"
   InstallInstallRecur "*.*", strPath   
   InstallAttributesRemove PathAddBackslash(strPath) & "*.*"   
   end if
  

 Main = blnRetVal                                                                   'Return true to indicate a successful
                                                                                    'update, or false for unsuccessful.
End Function





'Optional: Function ErrorHandler
'It is preferable that you do your own error handling within your script using "On Error Resume Next" and
'"If Err.Number =..." because there is no way to resume or resume next once an error has occured.

Function ErrorHandler(strInstallPath, lngErrorNumber, strDescription, lngLine, lngColumn, strText)
   'Return 0             - Abort this install
   'Return 1             - Resume
   'Return 2             - Resume Next
   'Return anything else - Exit wizard

   'This is a copy of the internal error handler the Update Wizard uses if you don't specify this function

   Select Case MsgBox("Error " & lngErrorNumber & ": " & strDescription & vbCrLf & vbCrLf & _
                         "Script error on line " & lngLine & ", column " & lngColumn & " occurred in" & vbCrLf & _
                         """" & strText & """" & vbCrLf & vbCrLf & _ 
                         "Click Abort to abort the installation process, Retry to restart the" & vbCrLf & _
                         "update on this drive, or Ignore to continue with the next drive.", _
                         vbApplicationModal Or vbExclamation Or vbMsgBoxSetForeground Or vbAbortRetryIgnore, "ErrorHandler")
      Case vbAbort
         ErrorHandler = 0
      Case vbIgnore
         ErrorHandler = 2
      Case vbRetry
         ErrorHandler = 1
      Case Else
         ErrorHandler = 3
   End Select
End Function

