Pre-Install Script - Post-Install Script Tabs

Pre-Install Script - Post-Install Script Tabs

Description

When editing an update, the Pre-Install / Post-Install Scripting tabs are used to define custom batch commands that will be executed before or after the update is installed. The process is the same for both tabs.

PreInstall PostInstall Script Tabs

The batch file commands can be defined by typing them in the space provided, or by using the copy and paste commands to input the commands. The following environment variables are available for use in the commands:

  • %PATHTOFIXES%: Contains the full path to the current folder with a trailing backslash. The %PATHTOFIXES%: variable will resolve to %ProgramData%\Lenovo\Lenovo Patch\Installation\InstallationSandbox#YYYY-MM-DD-T-HH-MM-SS\. This variable is generated during the update procedure on the endpoint and should not be altered.
  • %LSFN%: The Language-Specific File Name variable provides a reference to the update file name and extension; the full path to the file is included. For example, if the update being deployed is LUCAgent1007, the %LSFN%: variable will resolve to %ProgramData%\Lenovo\Lenovo Patch\Installation\InstallationSandbox#YYYY-MM-DD-T-HH-MM-SS\LUCAgent1007.exe. This variable is generated during the update installation procedure on the endpoint and should not be altered.

Example 1: Expand and Display Variables

This script is an example to expand and display the %PATHTOFIXES% and %LSFN% variables to show the actual values.

Script

@Echo Begin Expand Variables Script>>.\Trace.txt
@Echo >>.\Trace.txt
@Echo Expand Variable – PATHTOFIXES>>.\Trace.txt
@Echo PATHTOFIXES: %PATHTOFIXES%>>.\Trace.txt
@Echo Expand Variable – LSFN>>.\Trace.txt
@Echo LSFN: %LSFN%>>.\Trace.txt
@Echo >>.\Trace.txt
@Echo End Expand Variables Script>>.\Trace.txt

Output

Text from the Trace.txt file.

Begin Expand Variables Script

Expand Variable – PATHTOFIXES
PATHTOFIXES: C:\ProgramData\Lenovo\Lenovo Patch\Installation\InstallationSandbox#2021-08-19-T-15-32-10\
Expand Variable – LSFN
LSFN: C:\ProgramData\Lenovo\Lenovo Patch\Installation\InstallationSandbox#2021-08-19-T-15-32-10\lucagent1007.exe

End Expand Variables Script

Example 2: Stop and Disable a Service

This script is an example on how to stop and disable the Print Spooler service on a device.

Script

@Echo Begin Stop / Disable Service Script>>.\Trace.txt
@Echo >>.\Trace.txt
@Echo Stop Print Spooler Service>>.\Trace.txt
@Echo Command - sc stop SPOOLER>>.\Trace.txt
sc stop SPOOLER
@Echo Disable Print Spooler Service>>.\Trace.txt
@Echo Command - sc config SPOOLER start=disabled>>.\Trace.txt
sc config SPOOLER start=disabled
@Echo >>.\Trace.txt
@Echo End Stop / Disable Service Script >>.\Trace.txt

Output

Text from the Trace.txt file.

Begin Stop / Disable Service Script

Stop Print Spooler Service
Command - sc stop SPOOLER
Disable Print Spooler Service
Command - sc config SPOOLER start=disabled

End Stop / Disable Service Script

Example 3: Execute Registry change using imported custom .REG file

This is a sample script showing how to execute an imported custom .REG file using the Custom Files tab to ensure the file is accessible during the Pre-Install / Post-Install script execution.

Script

@Echo Begin Execute Registry change from .REG file Script>>.\Trace.txt
@Echo >>.\Trace.txt
@Echo Execute Registry Change>>.\Trace.txt
@Echo Command - Regedit /s "%PATHTOFIXES%Registry.REG">>.\Trace.txt
Regedit /s "%PATHTOFIXES%Registry.REG"
@Echo >>.\Trace.txt
@Echo End Execute Registry change from .REG file Script>>.\Trace.txt

Output

Text from the Trace.txt file.

Begin Execute Registry change from .REG file Script

Execute Registry Change 
Command - Regedit /s " C:\ProgramData\Lenovo\Lenovo Patch\Installation\InstallationSandbox#2021-08-19-T-15-32-10\Registry.REG"

End Execute Registry change from .REG file Script

Example 4: Execute PowerShell script using an imported custom .PS1 file

This is a sample script showing how to execute an imported custom .PS1 file using the Custom Files tab to ensure the file is accessible during the Pre-Install / Post-Install script execution.

Script

@Echo Begin Execute PowerShell Script using .PS1 file Script>>.\Trace.txt
@Echo >>.\Trace.txt
@Echo Edit Registry>>.\Trace.txt
@Echo Command - PowerShell.exe -Command " . '%PATHTOFIXES%POWERSHELL.PS1'">>.\Trace.txt
PowerShell.exe -Command " . '%PATHTOFIXES%POWERSHELL.PS1'"
@Echo >>.\Trace.txt
@Echo End Execute PowerShell Script using .PS1 file Script >>.\Trace.txt

Output

Text from the Trace.txt file.

Begin Execute PowerShell Script using .PS1 file Script

Execute PowerShell script 
Command – PowerShell.exe.exe -Command " . 'C:\ProgramData\Lenovo\Lenovo Patch\Installation\InstallationSandbox#2021-08-19-T-19-17-07\POWERSHELL.PS1'"

End Execute PowerShell Script using .PS1 file Script
    • Related Articles

    • How to Download and Install Blancco

      Prerequisites You must have valid access credentials (username / password) to the BMP portal or software repository. Your system must meet the minimum system requirements (OS version, disk space, memory, etc.). Administrative privileges on the target ...
    • Getting Started: Drive Eraser

      This guide provides the essential steps for initiating a secure data erasure session using Lenovo | Blancco Drive Eraser bootable media. Use this procedure to permanently sanitize storage devices (HDDs, SSDs, NVMe) in preparation for asset ...
    • Getting Started - Links and Prerequisites

      1. Lenovo Patch User Guide, Upgrade Guide, and Release Notes Lenovo Patch 2.5 User Guide Lenovo Patch 2.5 Upgrade Guide Lenovo Patch 2.5 Release Notes Lenovo Patch End-User License Agreement These release notes support the current version of Lenovo ...
    • Downloading and Installing Cigent

      There are two types of installation packages available. The executable (EXE) is a user interactive Installation suitable for manual installations, while the Microsoft Standard Installer (MSI) is designed for remote deployments and does not require ...
    • Getting Started: File Eraser

      Install or launch File Eraser If not already installed, deploy Blancco File Eraser and activate with a valid license. Open the application. Select files or folders to erase Use the interface to browse to desired files/folders. Alternatively, drag & ...