SetupComplete.cmd & Related Registry Values

Ever wonder what triggers the SetupComplete.cmd file after Windows Installs / Windows Upgrades? It’s actually just a couple of registry values.

HKEY_LOCAL_MACHINE\SYSTEM\Setup
CmdLine | REG_SZ | C:\Windows\Setup\Scripts\SetupComplete.cmd
SetupType | DWord | 2

When you run an upgrade, you can use the postoobe switch to set that value to a different location, which is what ConfigMgr does to use it’s own custom SetupComplete.cmd file.

Lets now consider the unsupported..

Knowing this, you can hijack those values for other things, like an app install, or running any command line you’d like at the next startup of the computer, before a user can logon. Sure there are scheduled tasks you could create, or run keys, but isn’t it fun to know you have other methods, and this will prevent the user from logging in until it’s completed.

In this example I’ve created a simple command file and placed in c:\windows\temp called PreLogon.cmd. I’ve updated those two registry values.

At the next reboot:

Wasn’t that fun? At least interesting if nothing else to understand how it works.

To understand more about the SetupComplete & SetupRollback, check out my other posts by searching those terms.

3 thoughts on “SetupComplete.cmd & Related Registry Values”

  1. Hi Gary. Definitely fun and games until you realize the default SCCM SetupComplete.cmd does one specific important thing – returning control to TS. Not to mention countless MS support engineers saying stuff like do not modify SetupComplete.cmd nor try to have your own passed via OSDSetupAdditionalUpgradeOptions TS parameter. But I agree that in a non-SCCM world this particular cmd is a huge benefit I definitely abuse it a lot 🙂

    Reply
    • Yes, you have to be pretty careful and know exactly what you’re doing if you’re going to modify it. If I use it, I typically only append to it, to make sure I don’t “undo” anything the CM team added.
      However, since the time I wrote this, there are now better methods to get things done. You can now leverage Custom Action Scripts, which will run at different points in the upgrade process, which the setup engine will call: https://garytown.com/windows-10-upgrade-custom-action-scripts

      Reply

Leave a Reply to gwblok Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.