This TID includes a method to automate application installation using Imaging Toolkit with ENGL/WDS Deployment.
The procedure details how to create a Windows server share containing an installation PowerShell script that is copied to the local machine and run by Imaging Toolkit during deployment. The install script supports running application setups (EXE/MSI) whilst sending status updates to the Monitor Service.
Requirements
- Imaging Toolkit 14.0 or later
- ENGL deployment (WinPE/WIM)
Procedure
- Ensure you have a working Imaging Toolkit automated deployment by following the documentation walkthrough.
- Create an apps folder on a server share, i.e. "\\myserver\myshare\apps".
- Start Build Console and open your ENGL Deployment project.
- From the Expert View, select Customisation > Custom Files, select and edit phase3-before.vbs, then add and save the following lines:
' Map a driver to share ' Note: Uncomment this section if the machine is not in a domain and/or needs authentication to the share. 'Dim objNetwork, strRemoteShare 'Set objNetwork = WScript.CreateObject("WScript.Network") 'strRemoteShare = "\\myserver\myshare" 'objNetwork.MapNetworkDrive "P:", strRemoteShare, False ' Copy installer script to local drive Dim objFileSystem Set objFileSystem = CreateObject("Scripting.FileSystemObject") objFileSystem.CreateFolder "c:\ztoolkit\apps" objFileSystem.CopyFile "\\myserver\myshare\apps\install-apps.ps1", "c:\ztoolkit\apps\" - From the Expert View, select Customisation > Applications, then set Enabled to True and the Command line to the following:
powershell.exe -ExecutionPolicy Bypass -File c:\ztoolkit\apps\install-apps.ps1
- Save the project.
- Run Deployment Wizard to recreate the build process add-on image (Ztoolkit.wim).
- Copy the updated Ztoolkit.wim to the imaging server.
- Create the following file in \\myserver\myshare\apps\install-apps.ps1:
############################################################# # ENGL Deployment - Install Applications Script # # Note: Must only be run as part of ENGL Imaging Toolkit # deployment process from "C:\Ztoolkit\Apps". ############################################################# # Intialise ENGL components $Monitor = new-object -comobject "ENGL.Ztoolkit.Monitor" $Utils = new-object -comobject "ENGL.Ztoolkit.Utils" # Enable verbose logging $Monitor.DebugLevel = 1 $Utils.DebugLevel = 1 # Globals $AppRootPath = "\\myserver\myshare\apps" $MachineName = Hostname # Install application and send status updates to ENGL Deployment Monitor function Engl_InstallAppNoWait($name, $cmdline, $arglist) { # Send status update - Started $Monitor.Task = "Installing $name" $Monitor.Status = "Started" $ret = $Monitor.SendUpdate() # Install application $utils.AppendLog("Installing $name...") $utils.AppendLog(" cmdline: '$cmdline'") $utils.AppendLog(" arglist: '$arglist'") Start-Process $cmdline -ArgumentList $arglist $utils.AppendLog(" ret: $status") # Send status update - Finished $Monitor.Task = "Installing $name" $Monitor.Status = "Finished" $ret = $Monitor.SendUpdate() } function Engl_InstallAppWait($name, $cmdline, $arglist) { # Send status update - Started $Monitor.Task = "Installing $name" $Monitor.Status = "Started" $ret = $Monitor.SendUpdate() # Install application $utils.AppendLog("Installing $name...") $utils.AppendLog(" cmdline: '$cmdline'") $utils.AppendLog(" arglist: '$arglist'") Start-Process $cmdline -ArgumentList $arglist -windowstyle minimized -wait $utils.AppendLog(" ret: $status") # Send status update - Finished $Monitor.Task = "Installing $name" $Monitor.Status = "Finished" $ret = $Monitor.SendUpdate() } # Example 1: Application install EXE #$ret = Engl_InstallAppWait "MyAppTitle" "$AppRootPath\MyAppFolder\MySetup.exe" "/install /quiet /norestart" # Example 2: Application install MSI #$ret = Engl_InstallAppWait "MyAppTitle" "msiexec" "/i $AppRootPath\apps\MyApp\MySetup.msi /qn" # Complete application install process (Imaging Toolkit continues build process) $utils.AppendLog("Completing application install process") $status = $utils.run("c:\ztoolkit\zmainrun.exe /build /lastappinstalled", 0, $false) - Modify the Powershell script to install applications for all machine builds. The example application installations can be replaced with your own application setups. Use the Engl_InstallAppNoWait to run a setup without waiting for it to exit (asynchronously) or Engl_InstallAppWait function to run a setup and wait for it to exit (synchronously). If you're not using the Monitor Service, comment out the lines containing "SendUpdate".