Displaying Front-End HTAs within a SCCM Task Sequence
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:
- Install MDT 2010 Update 1 on your local computer
- Find ServiceUI.exe (for the appropriate target architecture) and put it into the same directory as your HTA front end script(s)
- 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- 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.
- 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.
- 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 ;-)
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.
Thanks
September 30, 2011 at 4:53 pm
Great! I hope it works out for your needs…
October 3, 2011 at 5:10 pm
[…] 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 […]
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.
January 24, 2012 at 6:31 am
Awesome, I appreciate the tip!!
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.
January 26, 2012 at 10:29 am
Thanks – I appreciate the additional info!
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?
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.
https://t3chn1ck.wordpress.com/2013/06/06/osd-options-chooser-v3/
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.
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”
September 4, 2013 at 4:23 pm
Good find, thanks for sharing the solution.
December 26, 2013 at 10:18 am
WOW!!!
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!
December 28, 2013 at 7:33 am
Glad this helped! Keep in mind this post was written for ConfigMgr 2007. There is a newer built-in process for ConfigMgr 2012.
December 29, 2013 at 12:35 am
nothing ive tried worked for CM12..
do you have that link for the newer built-in process?
January 7, 2014 at 8:51 pm
Golan, this is the built-in process for CM12
http://www.petervanderwoude.nl/post/add-hta-support-to-a-boot-image-with-configmgr-2012/
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.
http://www.niallbrady.com/2014/08/03/how-can-i-dynamically-deploy-multiple-operating-systems-with-system-center-2012-r2-configuration-manager/#comment-899
Be sure to read the comment section at the bottom mentioning the two need prerequisites.
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 :-)