Displaying Front-End HTAs within a SCCM Task Sequence

Posted on Updated on

I’ve often heard the phrase “MDT solves problems to issues you didn’t even know you had.”  And it’s certainly true in this case!!

I was  looking for a process or procedure that would allow me to present my current custom OSD front end HTA to an active end-user who is logged into Windows.  Unfortunately, standard SCCM task sequences don’t allow this to happen.  To workaround this, my first consideration was to run the HTA as a prerequisite of the task sequence, but therein lay another issue with SCCM task sequences – since the HTA was run as a prerequisite Program, it was not technically within the Task Sequence environment and therefore I could not set task sequence variables, etc.

Fortunately the good folks on the MyITForum discussion list were able to steer me in the right direction.  MDT 2010 Update 1 contains a standalone executable (ServiceUI.exe) that allows execution of anything (not just an HTA) within a task sequence and enables the end-user to interact with it.  To utilize ServiceUI without integrating MDT with SCCM, perform the following:

  1. Install MDT 2010 Update 1 on your local computer
  2. Find ServiceUI.exe (for the appropriate target architecture) and put it into the same directory as your HTA front end script(s)
  3. Create a script that will
    a)  Make a copy of the HTA on the local executing computer (only if your advertisement is set to “run from server”)
    b)  Run command: ServiceUI.exe -session:1 %WINDIR%\system32\mshta.exe C:\CustomSystemOptions.hta

    1. Note 1: it’s important to know that the options “-session:1” will only work if the user logged into Windows has local admin rights.  My suggestion is to restart Windows and login as the local Administrator account.
    2. Note 2: Thanks to Ryan for feedback that when running on a 64-bit system, use %WINDIR%\SYSWOW64\mshta.exe
      The exception to this note is if you’re using SCCM 2012 … then it must use mshta.exe from System32.
  4. Update your task sequence to include a “Run Command Line” as the very first item in the task sequence
    a)  Name it something like “Service UI – Custom System Options”
    b)  Set the command line as “TheNameOfYourScript.vbs”
    c)  Use the package which contains your scripts
    d)  CRITICAL: Do not set option “Time-out (minutes)” as this will cause ServiceUI to error!
    e)  On the Options tab, add a condition to check that TS variable “_SMSTSInWinPE” = false

In short, this should be all that you need to get going to display the HTA to end-user.  However, the thing that I do not yet have resolved in this all this is that when connected to a system through RDP, ServiceUI will launch the HTA, but it’s not displayed.  Still gotta figure that one out….and then update this post of course ;-)


18 thoughts on “Displaying Front-End HTAs within a SCCM Task Sequence

    jay connor said:
    September 30, 2011 at 4:17 pm

    I run a script as a pre-req using the registry to store information I want in the task sequence. When the Task Sequence runs it can then read the registry.

    Willl have to play with this.

      Nicolas Moseley responded:
      September 30, 2011 at 4:53 pm

      Great! I hope it works out for your needs…

    […] an SCCM Task Sequence October 3, 2011 robertrieglerwien Leave a comment Go to comments https://t3chn1ck.wordpress.com/2011/09/30/displaying-front-end-htas-within-an-sccm-task-sequence/ Share this:PrintEmailLike this:LikeBe the first to like this post. Categories: MS: Deployment […]

    Matt said:
    January 24, 2012 at 4:52 am

    hey mate, nice article , could come in very handy for a problem i’m working on.

    Just a tip – if you use -session:1 , thats always the console session. RDP will be another session, could be 2, or 3 etc. You would need to use some logic to determine the session and set that as a variable for the TS command line.

    powershell can manipulate sessions and find the session id for a specific user etc.

    Texas said:
    January 26, 2012 at 10:25 am

    I go to the Interaction tab on your Advertisement and check the box “Show the task sequence progress”. Then run a command line in the task sequence ServiceUI.exe -process:tsprogressui.exe %SYSTEMROOT%\system32\mshta.exe my.hta. Found it on another site and as long as you dont mind moving the progress bar out of the way it is a quick and dirty way to ensure the HTA displays in your current session.

      Nicolas Moseley responded:
      January 26, 2012 at 10:29 am

      Thanks – I appreciate the additional info!

    Ryan said:
    August 29, 2013 at 8:13 am

    I am working on the same issue, I am able to get the HTA to display to the user within Windows as a prerequisite action in the task. But, I am unable to pass the variables with “Microsoft.SMS.TSEnvironment” object because it can not create the object. How are you passing the variables to the task sequence?

      N. Moseley responded:
      August 29, 2013 at 10:02 am

      The VBScript object Microsoft.SMS.TSEnvironment (inside your HTA) should be the one writing those to the Task Sequence.


        Ryan said:
        August 30, 2013 at 7:24 am

        Yes, I am using the object within the script section of my HTA set env = CreateObject(“Microsoft.SMS.TSEnvironment”) but, I get a scripting error, ActiveX component can not be created. As if it is not running in the task sequence. Now this is in Windows before rebooting in to PE but, it is still an action of the task sequence.

        Ryan said:
        September 4, 2013 at 8:43 am

        The issue that I was having was executing the HTA on a x64 system. The COMObject Microsoft.SMS.TSEnvironment does not work in a 32-bit process on a 64-bit system. Once I changed my task to launch using the following command the COMObject started working.

        %ToolRoot%\ServiceUI.exe -process:tsprogressui.exe %SYSTEMROOT%\sysWOW64\mshta.exe “%scriptroot%\Custom.hta”

        N. Moseley responded:
        September 4, 2013 at 4:23 pm

        Good find, thanks for sharing the solution.

    Golan said:
    December 26, 2013 at 10:18 am


    you stopped a MAJOR headache that im having during the past year!

    thank you very much for your post, I have succeeded of making it work!

    Shawn John said:
    May 21, 2015 at 2:13 pm

    This helped me realize I needed to integrate MDT into SCCM but I ended up following this guide to successfully get HTA working with SCCM 2012.


    Be sure to read the comment section at the bottom mentioning the two need prerequisites.

      N. Moseley responded:
      May 21, 2015 at 7:29 pm

      Shawn, I appreciate the feedback. This guide was written for CM07, so this here improved much since then to make easier for all of us :-)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s