Skip to content

Commit

Permalink
Added sample script to install Visual C++ runtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
arwidmark committed Mar 14, 2017
1 parent f7564d1 commit 9cc6a3c
Showing 1 changed file with 302 additions and 0 deletions.
302 changes: 302 additions & 0 deletions Scripts/Install-MicrosoftVisualC++x86x64.wsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
<job id="Install-MicrosoftVisualC++x86x64">
<script language="VBScript" src="..\..\scripts\ZTIUtility.vbs"/>
<script language="VBScript">

'//----------------------------------------------------------------------------
'// Purpose: Used to install Microsoft Visual C++ Redistributable Packages
'//
'// Usage: cscript Install-MicrosoftVisualC++x86x64.wsf [/debug:true]
'// Version: 1.1 - August 8, 2012 - Johan Arwidmark
'// Version: 2.1 - June 26, 2014 - Mikael Nystrom
'// Version: 2.2 - March 12, 2017 - Johan Arwidmark
'//
'// Disclaimer:
'// This script is provided "AS IS" with no warranties, confers no rights and
'// is not supported by the authors or Deployment Artist.

Option Explicit
Dim iRetVal

'On Error Resume Next
iRetVal = ZTIProcess
ProcessResults iRetVal
On Error Goto 0

'//---------------------------------------------------------------------------
'// Function: ZTIProcess()
'//---------------------------------------------------------------------------
Function ZTIProcess()

oLogging.CreateEntry oUtility.ScriptName & ": Starting installation", LogTypeInfo

Dim sSetupFile2005x86
Dim sSetupFile2005x64
Dim sSetupFile2008x86
Dim sSetupFile2008x64
Dim sSetupFile2010x86
Dim sSetupFile2010x64
Dim sSetupFile2012x86
Dim sSetupFile2012x64
Dim sSetupFile2013x86
Dim sSetupFile2013x64
Dim sSetupFile2015x86
Dim sSetupFile2015x64


Dim sArguments

'// Disable Zone Checks
oEnv("SEE_MASK_NOZONECHECKS") = 1

'// Note: You need to create the below folder structure and downloading the various redistributable packages from Microsoft
'// https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

sSetupFile2005x86 = oUtility.ScriptDir & "\Source\VC2005\vcredist_x86.exe"
sSetupFile2005x64 = oUtility.ScriptDir & "\Source\VC2005\vcredist_x64.exe"
sSetupFile2008x86 = oUtility.ScriptDir & "\Source\VC2008\vcredist_x86.exe"
sSetupFile2008x64 = oUtility.ScriptDir & "\Source\VC2008\vcredist_x64.exe"
sSetupFile2010x86 = oUtility.ScriptDir & "\Source\VC2010\vcredist_x86.exe"
sSetupFile2010x64 = oUtility.ScriptDir & "\Source\VC2010\vcredist_x64.exe"
sSetupFile2012x86 = oUtility.ScriptDir & "\Source\VC2012\vcredist_x86.exe"
sSetupFile2012x64 = oUtility.ScriptDir & "\Source\VC2012\vcredist_x64.exe"
sSetupFile2013x86 = oUtility.ScriptDir & "\Source\VC2013\vcredist_x86.exe"
sSetupFile2013x64 = oUtility.ScriptDir & "\Source\VC2013\vcredist_x64.exe"
sSetupFile2015x86 = oUtility.ScriptDir & "\Source\VC2015\vc_redist.x86.exe"
sSetupFile2015x64 = oUtility.ScriptDir & "\Source\VC2015\vc_redist.x64.exe"

sArguments = "/Q"

'Checking for x86 files
If not oFSO.FileExists(sSetupFile2005x86) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2005x86 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

If not oFSO.FileExists(sSetupFile2008x86) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2008x86 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

If not oFSO.FileExists(sSetupFile2010x86) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2010x86 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

If not oFSO.FileExists(sSetupFile2012x86) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2012x86 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

If not oFSO.FileExists(sSetupFile2013x86) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2013x86 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

If not oFSO.FileExists(sSetupFile2015x86) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2015x86 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if


'Installing x86 files
oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2005x86, LogTypeInfo

iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2005x86 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2008x86, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2008x86 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2010x86, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2010x86 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2012x86, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2012x86 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2013x86, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2013x86 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2013x86, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2015x86 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

' If x64 operating system, also install x64 version
If oEnvironment.Item("Architecture") = "X64" then

'Checking for x64 files
If not oFSO.FileExists(sSetupFile2005x64) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2005x64 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

If not oFSO.FileExists(sSetupFile2008x64) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2008x64 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

If not oFSO.FileExists(sSetupFile2010x64) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2010x64 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

If not oFSO.FileExists(sSetupFile2012x64) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2012x64 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

If not oFSO.FileExists(sSetupFile2013x64) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2013x64 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

If not oFSO.FileExists(sSetupFile2015x64) then
oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile2015x64 & " was not found, unable to install", LogTypeError
ZTIProcess = Failure
Exit Function
End if

'Installing x64 files
oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2005x64, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2005x64 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2008x64, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2008x64 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2010x64, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2010x64 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2012x64, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2012x64 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2013x64, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2013x64 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2015x64, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2015x64 & """ " & sArguments)

if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
End If

oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo

End If

'/// Enable Zone Checks
oEnv.Remove("SEE_MASK_NOZONECHECKS")

End Function

</script>
</job>

0 comments on commit 9cc6a3c

Please sign in to comment.