The Tasks tab in the advanced settings of the Answer File Wizard gives you the option of creating custom tasks that will run during deployment. This is a great way to run scripts and execute other commands during different phases of deployment. Here you'll find some important notes and tips to consider when you create your tasks.
Tasks can be configured to run during one of the following phases of deployment:
- PREIMAGE: Before the image is applied (in WindowsPE, before the disk is configured or the image is applied - this is uncommon)
- POSTIMAGE: After the image is applied (in WindowsPE, after the image is applied, right before rebooting)
- SPECIALIZE: Specialize/Mini-Setup (after reboot, during Sysprep)
- FIRSTBOOT: Upon first boot as system (occurs behind the Windows login screen, executed under the authority of the LOCALSYSTEM account - this is the phase we recommend for software installation Tasks)
FIRSTLOGON: Upon first logon to desktop (executed using a RunOnce key in the Windows registry, under the authority of whichever user logs in first)
(Optional) Copy Your Scripts to a Folder on Your Reference VM
If you plan to run any scripts during deployment, the easiest method to make them available on the deployed endpoint is to copy your scripts and/or software packages to an easy-to-remember location on your Reference VM, such as C:\Software, before you capture your image. This simplifies the process by eliminating the need to authenticate to network shares when accessing files referenced in your tasks or scripts, and you can just call this file directly from the local hard drive.
Tasks are executed exactly as entered, as if they were executed from a command prompt. Depending on the type of script or executable you want you run, you'll need to format your task command differently to ensure that it runs properly. If you wish to test any of your commands prior to adding them as Tasks, you can open a WindowsPE command prompt from the SmartDeploy splash screen, or open an administrative command prompt in the deployed Windows OS, and try running the commands manually before adding them to your answer file.
Note: In WindowsPE, after the image is applied, the Windows file system - i.e. the drive that will be known as C:\ after the device reboots - will be mounted as T:\. If you wish to call any script files from the C:\Software folder that existed on your reference VM, and which now exists on the deployed endpoint, you would use T:\Software. For any subsequent phases after reboot, you can use C:\Software to refer to this folder.
- Batch Script (.BAT): cmd.exe /c C:\Software\MyScript.bat
- VBS Script (.VBS): wscript.exe C:\Software\MyScript.vbs
- PowerShell (.PS1): powershell.exe -NoProfile -NonInteractive -ExecutionPolicy bypass -file C:\Software\MyScript.ps1
- Executable (.EXE): C:\Software\MyApplication.exe /S
Note: Refer to the application documentation to confirm the silent installation parameters when installing from command line.
- MSI (.MSI): msiexec.exe /i C:\Software\MyApplication.msi /quiet /norestart
Note: Refer to the application documentation to confirm the silent installation parameters when installing from a command line.
Example syntax is not intended for use with Application Packs
Note that the example syntax above is only intended for the Tasks tab in the Answer File Wizard advanced options.
Users of Application Packs may note that SmartDeploy automatically adds this syntax when commands are executed inside of a Run Command task in an app pack. See: Create a Custom Application Pack (Advanced)
Using executables and scripts on your SmartDeploy media
When you create boot media or offline deployment media, you have the option to include additional files. Files that you select here will be saved to the z folder on the root of your boot media.
If you want to use one of these files in an Answer File task, you would set the path to use the variable, %SmartDeploy_Media%, which refers to the root directory of your SmartDeploy media. Note that this variable only exists in WindowsPE, so it can only be used for PREIMAGE or POSTIMAGE tasks.
- VBS script (.VBS): wscript.exe %SmartDeploy_Media%\z\YourScript.vbs