Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


How to determine when sysprep has finished executing FirstLogonCommands?

Recommended Posts


I'm trying to determine the best way to programmatically detect when sysprep has finished executing all SynchronousCommands in FirstLogonCommands from C:\Windows\Panther\unattend.xml.

I'd like to do this without having to do something special in unattend.xml, like write to a file as the last command and then if the file exists, then this determines sysprep has finished.

I'm wondering if the commands in unattend.xml are written to the registry (like HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce) and then the commands are actually run from the registry?

Or does sysprep parse the commands and runs them directly from unattend.xml?

What I currently have in mind is as follows:

1. Parse unattend.xml

2. For each SynchronousCommand parse the CommandLine to get the executable

3. Wait until all executables are not running.

I'm just wondering if there's a better way because this process is error-prone in at least two ways:

1. There may be a gap in-between the time subsequent SynchronousCommands are run.

2. This process will wait indefinitely if CommandLine contains a process which is the same as one that is run in the background as a service for example.

Thank you.

Share this post

Link to post
Share on other sites

Well, sysprep doesn't do any of this actually. What it does do is create the unattend.xml. If you specify one with /unattend switch or not, it will make one. If you look in the setupact.log file in UnattendGC, you will be able to see that msoobe.exe is what reads the XML and then runs the commands. Do a test deployment and then take a look at the log to see how things are being handled.

The key to remember is that sysprep only runs until the system is shut down. When you turn it back on again, or on first boot after redeploy, sysyprep does not run again.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...