With as often as I deploy software, I created a standard VBScript template to use when needing to create an unattended application installation. One thing that I do not have in this script is and uninstall procedure, which I usually do when deploying software, as to uninstall the older version before installing the newer. I do not depend on the application installation to take care of the uninstall of older versions because I have run across too many apps in the past that did not properly uninstall before starting the new install.
So in this script, the parts you will need to modify are the global variable LogFolderName to be the name of the folder you wish for placing the log file at. The TempFolder constant may also need to be changed if you do not wish for the log file folder to be under c:\temp.
If this is a simple MSI installer, I have already completed most of the script for deploying the MSI. The only part that might need to be inserted is if there is a transform file.
You can download the script from here.
So in this script, the parts you will need to modify are the global variable LogFolderName to be the name of the folder you wish for placing the log file at. The TempFolder constant may also need to be changed if you do not wish for the log file folder to be under c:\temp.
If this is a simple MSI installer, I have already completed most of the script for deploying the MSI. The only part that might need to be inserted is if there is a transform file.
You can download the script from here.
'*******************************************************************************
' Program: Install.vbs
' Author:
' Date:
' Modified:
'
' Program:
' Version:
' Description: This will install
' 1) Define the relative installation path
' 2) Create the Log Folder
' *) Install
' *) Cleanup Global Variables
'*******************************************************************************
Option Explicit
REM Define Constants
CONST TempFolder = "c:\temp\"
CONST LogFolderName = ""
REM Define Global Variables
DIM LogFolder : LogFolder = TempFolder & LogFolderName & "\"
DIM RelativePath : Set RelativePath = Nothing
REM Define the relative installation path
DefineRelativePath()
REM Create the Log Folder
CreateLogFolder()
REM Install
Install
REM Cleanup Global Variables
GlobalVariableCleanup()
'*******************************************************************************
'*******************************************************************************
Sub DefineRelativePath()
REM Get File Name with full relative path
RelativePath = WScript.ScriptFullName
REM Remove file name, leaving relative path only
RelativePath = Left(RelativePath, InStrRev(RelativePath, "\"))
End Sub
'*******************************************************************************
Sub CreateLogFolder()
REM Define Local Objects
DIM FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
If NOT FSO.FolderExists(TempFolder) then
FSO.CreateFolder(TempFolder)
End If
If NOT FSO.FolderExists(LogFolder) then
FSO.CreateFolder(LogFolder)
End If
REM Cleanup Local Variables
Set FSO = Nothing
End Sub
'*******************************************************************************
Sub Install()
REM Define Local Objects
DIM oShell : SET oShell = CreateObject("Wscript.Shell")
REM Define Local Variables
DIM MSI : MSI = Chr(32) & RelativePath & ".msi"
DIM Logs : Logs = Chr(32) & "/lvx" & Chr(32) & LogFolder & ""
DIM Parameters : Parameters = Chr(32) & "/qb- /norestart"
DIM Transforms : Transforms = Chr(32) & "Transforms=" & RelativePath & ""
DIM Install : Install = "msiexec.exe /i" & MSI & Logs & Parameters
oShell.Run Install, 1, True
REM Cleanup Local Variables
Set Install = Nothing
Set Logs = Nothing
Set MSI = Nothing
Set oShell = Nothing
Set Parameters = Nothing
Set Transforms = Nothing
End Sub
'*******************************************************************************
Sub GlobalVariableCleanup()
Set LogFolder = Nothing
Set RelativePath = Nothing
End Sub
Better way to write DefineRelativePath().
ReplyDeleteSub DefineRelativePath()
REM Get File Name with full relative path
Set fso = CreateObject("Scripting.FileSystemObject")
RelativePath = fso.GetParentFolderName(WScript.ScriptFullName)
End Sub