As a discovery exercise, I created a small, stand-alone app using AutoIT that displays a dialog box with the current value of the environment variables USERNAME and USERDOMAIN, and then waits for the OK button to be pushed. I then added this app to a ConfigMgr package and called it using a command-line task in various places in a task sequence. Here are the results using just a basic deployment task sequence:
Before PE
Launching the application via a TS advertisement before the initial reboot into PE stopped the whole TS flat. The message box was launched as the local SYSTEM on a different window station and thus wasn’t shown on the current user’s desktop. My only option was to kill it using Task Manager which caused the whole TS to fail because a failure code is sent back to the TS.
After PE, Before Image deployment
In this one, the app launched as the local SYSTEM and showed up on the PE desktop fine. The TS waited for me to click OK before going on.
After Image Copy, Before Mini-setup/OOBE
Not surprisingly, this step resulted in the same thing as the last one as we are are still in PE and nothing has changed.
After Mini-setup/OOBE
This is the last one I tested and gave weird results. At this point in the TS, we’re actually in the OS deployed and not PE. The message box appeared just fine, but the environment variables I was keying on didn’t exist (I confirmed this by pressing F8 and reviewing the output of the set command). I’m assuming this is still the local SYSTEM account, but my current method doesn’t prove that one way or another; I need to find a new way to check for the user context and re-run this step of the test.