Zum Inhalt springen

MDT – Visual C++ Wrapper-Skript erweitern

Wer mit dem MDT (Microsoft Deployment Toolkit) arbeitet und stets alle vorhandenen Visual C++ Redistributables ausrollen möchte, der kommt wegen des Komforts nicht an dem Blogeintrag des “Deployment Bunny” vorbei.
Damit und mit diesem Wrapper-Skript für das automatisierte Herunterladen bleiben kaum Wünsche offen.
Momentan sind die Skripte noch nicht für Visual C++ 2017 Redistributables angepasst.
Um das Ganze selbst anzupassen sind nur wenige Handgriffe notwendig.

Download.xml im Wrapper-Skript

Für den Download ist es nur notwendig die folgende Zeilen in der download.xml vor den abschließenden </Download> einzufügen:
<DownloadItem>
<Comment></Comment>
<FullName>Visual C++ Redistributable for Visual Studio 2017 (x86)</FullName>
<ShortName>VS2017X86</ShortName>
<Source>https://download.microsoft.com/download/1/f/e/1febbdb2-aded-4e14-9063-39fb17e88444/vc_redist.x86.exe</Source>
<DestinationFolder>VS2017</DestinationFolder>
<DestinationFile>vc_redist.x86.exe</DestinationFile>
<URL>http://www.microsoft.com</URL>
<CommandType>NONE</CommandType>
<Command></Command>
<CommandLineSwitches></CommandLineSwitches>
<VerifyAfterCommand></VerifyAfterCommand>
</DownloadItem>
<DownloadItem>
<Comment></Comment>
<FullName>Visual C++ Redistributable for Visual Studio 2017 (x64)</FullName>
<ShortName>VS2017X64</ShortName>
<Source>https://download.microsoft.com/download/3/b/f/3bf6e759-c555-4595-8973-86b7b4312927/vc_redist.x64.exe</Source>
<DestinationFolder>VS2017</DestinationFolder>
<DestinationFile>vc_redist.x64.exe</DestinationFile>
<URL>http://www.microsoft.com</URL>
<CommandType>NONE</CommandType>
<Command></Command>
<CommandLineSwitches></CommandLineSwitches>
<VerifyAfterCommand></VerifyAfterCommand>
</DownloadItem>

Im Application-Verzeichnis des MDT “Install-MicrosoftVisualC++x86x64.wsf”

Um das Installations-Skript anzupassen ist etwas mehr Aufwand notwendig.
Dazu muss man die “Install-MicrosoftVisualC++x86x64.wsf”-Datei an sechs Stellen editieren.

Die jeweiligen Stellen und der Code sind unten angeführt. Einfach Kopieren und an der richtigen Position einfügen und “fertig”.

Vor der Zeile “Dim sArguments”

Dim sSetupFile2017x86
Dim sSetupFile2017x64

Vor der Zeile “sArguments = “/Q””

sSetupFile2017x86 = oUtility.ScriptDir & "\Source\VS2017\vc_redist.x86.exe"
sSetupFile2017x64 = oUtility.ScriptDir & "\Source\VS2017\vc_redist.x64.exe"

Vor der Zeile “Installing x86 files”

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

Vor der Zeile “If x64 operating system, also install x64 version”

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2017x86, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2017x86 & """ " & 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

Vor der Zeile “Installing x64 files”

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

Vor der Zeile “End If” mit der darauffolgenden Zeile “/// Enable Zone Checks”

oLogging.CreateEntry oUtility.ScriptName & ": About to install " & sSetupFile2017x64, LogTypeInfo
iRetVal = oUtility.RunWithHeartbeat("""" & sSetupFile2017x64 & """ " & 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

Wer die Dateien manuell herunterladen möchte, der findet sie hier (x86) und hier (x64).