Adding Custom Tasks To Task Sequences | Quisitive
Adding Custom Tasks To Task Sequences
December 16, 2010
Discover our key points in the blog.

I was discussing Task Sequence customizations with a colleague today and he sent me a link to and older post by the ever knowledgeable Michael Niehaus.  Reading through it was a great reminder of the do’s and don’ts when working with Task Sequence’s. 

Read Michael’s full post here.

Some key points from his post:

  • Command lines that contain spaces need to be surrounded by quotes.  The parameters to those commands should not be included in the quotes (although some of them may also require quotes, depending on the command being executed).
  • Working directories should not have quotes. 
  • The task sequencer will set the working directory via a Windows API (which doesn’t need quotes) before launching the command.Avoid characters that look like XML, e.g. >, <, &, as these could cause XML parsing errors.Batch files can’t have UNC path working directories. 
  • CMD.EXE does not support this, so if you specify a working directory that is a UNC path, then execute CMD.EXE or a batch file that implicitly invokes CMD.EXE, the working directory will likely end up being set to C:\WINDOWS\SYSTEM32 – possibly harmless, depending on what your batch file does, but if the working directory is necessary to find the batch file, then there is a problem.
  • Know the difference between a command processed by CMD.EXE and an executable in its own right.
  • Don’t specify CMD.EXE commands directly without using a batch file or a “CMD.EXE /C” prefix. A few examples:
  • NET.EXE can be used directly (with or without the .exe)
  • XCOPY.EXE can be used directly (with or without the .exe)
  • COPY must be used with “CMD.EXE /C”, e.g. “CMD.EXE /C COPY C:\BLAH C:\BLAH2”, or used in a batch file.
  • MD or MKDIR must be used with “CMD.EXE /C”, or used in a batch file.
  • Other examples of commands built into CMD.EXE:  CLS, DIR, COLOR, DATE, ECHO, ERASE, EXIT, FIND, LABEL, MOVE, PATH, RD, RMDIR, START, TYPE
  • Other examples of commands that are stand-alone executables: ROBOCOPY, XCACLS, FORMAT, DISKPART, TASKKILL, SC, GPUPDATE
  • Don’t specify a working directory of “.\anything” (e.g. “.\Applications”) in the task sequence because the current working directory is not guaranteed. (Notice that when you add an application from Workbench, which does use this “.\” notation, it translates “.\” into “%DEPLOYROOT%\”. This is done at deploy time by the ZTIApplications.wsf script.)
  • The task sequencer expects all actions to indicate whether they were successful via the exit code (return code).  By default, exit code 0 and 3010 (reboot required) are considered to be successful, and all other values are considered failures.  If you task returns something other than 0 or 3010, be sure to add those valid values to the list of successful return codes on the “Options” pane.  (You can also modify your batch file to include an “exit 0” statement to force a success return code, when appropriate.)