Requirements

  • Imaging Toolkit 11.0.9
  • ENGL Deployment (WinPE/WIM)


Procedure

  1. Ensure you have a working automated deployment by following the documentation walkthrough.

  2. Create an apps folder,i.e. "\\myserver\myshare\apps".

  3. Start Build Console and open your ENGL Deployment project.

  4. 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\"
  5. 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
  6. Save the project.

  7. Run Deployment Wizard to recreate the build process add-on image (Ztoolkit.wim).

  8. Copy the updated Ztoolkit.wim to the imaging server.

  9. 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 application installation
    $ret = Engl_InstallAppWait "MyAppTitle" "$AppRootPath\MyAppFolder\MySetup.exe" "/install /quiet /norestart"
    
    # 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)
  10. Modify the Powershell script to install applications for all machine builds. The "Example application installation" is an example and 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 ENGL Deployment Monitor, comment out the lines containing "SendUpdate".