Prestart Commands for Task Sequence Media in Configuration Manager


Updated: May 14, 2015

Applies To: System Center 2012 Configuration Manager, System Center 2012 Configuration Manager SP1, System Center 2012 Configuration Manager SP2, System Center 2012 R2 Configuration Manager, System Center 2012 R2 Configuration Manager SP1

You can create a prestart command in System Center 2012 Configuration Manager to use with boot media, stand-alone media, and prestaged media. The prestart command is a script or executable that runs before the task sequence is selected and can interact with the user in Windows PE. The prestart command can prompt a user for information and save it in the task sequence environment or query a task sequence variable for information. When the destination computer boots, the command-line is run before the policy is downloaded from the management point. Use the following procedures to create a script to use for the prestart command, distribute the content associated with the prestart command, and configure the prestart command in media.

Create a Script File to Use for the Prestart Command

Task Sequence variables can be read and written by using the Microsoft.SMS.TSEnvironment COM object while the task sequence is running. The following example illustrates a Visual Basic script file that queries the _SMSTSLogPath task sequence variable to get the current log location. The script also sets a custom variable.

dim osd: set env = CreateObject("Microsoft.SMS.TSEnvironment")
dim logPath
' You can query the environment to get an existing variable.
logPath = env("_SMSTSLogPath")
' You can also set a variable in the OSD environment.
env("MyCustomVariable") = "varname"

Create a Package for the Script File and Distribute the Content

After you create the script or executable for the prestart command, you must create a package source to host the files for the script or executable, create a package for the files (no program required), and then distribute the content to a distribution point.

For more information about creating a package, see How to Create Packages and Programs in Configuration Manager.

For more information about distributing content, see the Distribute Content on Distribution Points section in the Operations and Maintenance for Content Management in Configuration Manager.

Configure the Prestart Command in Media

You can configure a prestart command in the Create Task Sequence Media Wizard for stand-alone media, bootable media, or prestaged media. For more information about the media types, see Planning for Media Operating System Deployments in Configuration Manager. Use the following procedure to create a prestart command in media.

To create a prestart command in media

  1. In the Configuration Manager console, click Software Library.

  2. In the Software Library workspace, expand Operating Systems, and then click Task Sequences.

  3. On the Home tab, in the Create group, click Create Task Sequence Media to start the Create Task Sequence Media Wizard.

  4. On the Select Media Type page, select Stand-alone media, Bootable media, or Prestaged media, and then click Next.

  5. Navigate to the Customization page of the wizard. For more information about configuring the other pages in the wizard, see How to Deploy Operating Systems by Using Media in Configuration Manager 

  6. On the Customization page, specify the following information, and then click Next.

    - Select **Enable prestart command**.
    - In the **Command line** text box, enter the script or executable that you created for the prestart command.
      <div class="alert">
      > [!IMPORTANT]
      > <P>Use <STRONG>cmd /C &lt;prestart command&gt;</STRONG> to specify the prestart command. For example, if you used TSScript.vbs as the name for your prestart command script, you would enter <STRONG>cmd /C TSScript.vbs</STRONG> for the command line. Where <STRONG>cmd /C</STRONG> opens a new Windows command interpreter window and uses the Path environment variable to find the prestart command script or executable. You can also specify the full path to the prestart command, but the drive letter could be different on computers with different drive configurations.</P>
    - Select **Include files for the prestart command**.
    - Click **Set** to select the package that is associated with the prestart command files.
    - Click **Browse** to select the distribution point that hosts the content for the prestart command.
  7. Complete the wizard.