As you probably know whenever you run a task sequence it will run as system. So you will not be able to query for user related information in a task sequence. You could of course make complex scripts that will check for logged in user and then check against Active directory or SCCM using a web service. But this is often a little project in order to complete it. I had a case where we wanted to deploy software with user specific settings based on where the user was employed. We found out that we wanted to use a task sequence for deploying this software, since it is more sexy to first uninstall any existing previous versions and then install the correct one. Okay, so we had a little challenge there in regards of those settings. But we managed to pull this one off really nice.
At first we thought that we could just run this in the task sequence and the user would be able to make a choice. But again, since this is running from Windows and not WinPE, we will not see anything that happens on the systems desktop. When you are in WinPE you will see the HTA because you are inside WinPE as the system account (no logon, remember).
This was our first challenge. How can we display this to the user. We found out that if we define this as program and use the “run this program first” on the properties on the task sequence we could achieve this:
start /wait mshta "%~dp0PreTS.hta"
This way the task sequence will wait until the hta is closed. (this could probably be solved in clever ways)
After putting this all together I ended up with problem number two. How should we keep the settings from the HTA as variables? I normally use HTA’s in task sequence and use the TS.ENV object to create Task sequence variables.
But wait a minute, this is not possible now because this is a program that runs before the task sequence…….. Back to problem solving again.
I ended up writing temporary keys to the registry (maybe a little dirty). So the HTA is programmed to write every output to HKLMSoftwareMSitPros .
I then use these registry keys as conditions inside the task sequence. I also run a cleanup step at the end, making sure I get rid of the MSitPros key in the registry.
Example task sequence and conditions:
First I create Group for the software installation and add a condition if the user choose to cancel in the HTA:
So when the user hits cancel in the HTA this will make sure that the task sequence skip right down to Cleanup. (Clever??)
(This runs from a package, but you could use UNC path)
And there you have it. It will only import the MSitPros registry settings if Employer is set to MSitPros in the registry.
If you want the HTA you can find it on our download page.
http://msitpros.com/?page_id=763 and it is called PreTS.hta.txt – Remember to rename it to just .HTA
Good luck. Hope you enjoyed this post.