Function MainScript()
 ' Echo out information to screen.
 If instr(lcase(wscript.FullName),lcase("cscript"))>0 Then wscript.Echo "Installing " & PackageName & vbCRLF & CommonName
  
 'Create a log file directory if it does Not exist
 CreateFolders

 ' Check to see if the package is installed
 Dim PackageInstalled : PackageInstalled = CheckPackage

 If PackageInstalled = True Then   ' (package is already installed and script can exit)
  oSh.LogEvent 0, PackageName & " is already installed"
  oSh.Run sTools & "\wlogevent.exe -c:4 -l:2 -ss:" & chr(34) & PackageName & "is already installed" & chr(34)
  wscript.quit(10)

 ElseIf PackageInstalled = False Then  ' (package has not yet been installed, copy it and install it)
  ' Check to see if the package has been copied
  Dim PackageCopied   : PackageCopied = CopyPackage

  If PackageCopied = True Then  ' (Source Exists and log file does not)
   ' Stop Defined processes
   On Error Resume Next
   Dim strProcess
   For Each strProcess In arrProcesses
    KillProcess strProcess
   Next
   On Error Goto 0

   ' Check for previous version of the application. If previous version exists uninstall it
   Dim x
   For x = 0 to UBOUND(PreviousInstalls)
    RemovePrevious PreviousInstalls(x), PackageName
   Next
   On Error GoTo 0

   ' Files have been copied, so now install.
   RunApplication

   'Check Application Product State
   Dim strGUID
   For Each strGUID In arrGUID
    validate strGUID
   Next
   On Error Goto 0

  ElseIf PackageCopied = False Or PackageCopied = null Then
   ' There was an unknown error while copying files, log error message
   oSh.LogEvent LogEventSuccess,PackageName & vbCRLF _
   & "There was an error while copying files" & vbCRLF
   ExitScript()         
  End If

  ElseIf PackageInstalled = Null Then  ' (Error with Function CheckPackage - error message)
   oSh.LogEvent LogEventSuccess,PackageName & vbCRLF _
   & "Error While Checking install State of "& PackageName
   ExitScript()

  Else  ' (Error with Function CheckPackage - error message)
   oSh.LogEvent LogEventSuccess,PackageName & vbCRLF _
   & "Error While Checking install State of "& PackageName _
   & "Function CheckPackage did not return True, False or Null."
   ExitScript()
  End If
End Function

0 Comments   [ + ] Show Comments

Comments

Please log in to comment

There are no answers at this time

Answers

Answer this question or Comment on this question for clarity