none
SetupType and CmdLine at HKEY_LOCAL_MACHINE\System\Setup

    Question

  • Does anyone have an explanation of the use of the following registry keys:

    HKLM\System\Setup

    SetupType:REG_DWORD

    CmdLine:REG_MULTI_SZ

    I'm now using these keys to automate some installation processes after loading a client machine with SysPrep.  Specifically I'm using CmdLine to trigger a script to run the CompleteImage phase of SQL Server 2008 R2 installation.  I have not been able to find good documentation, particularly on the possible values for SetupType and their meanings.

    I've found that with SetupType set to 0x01, the script referenced by CmdLine executes before the Windows logon screen is displayed, and when the script is complete the system reboots.  However, during the script execution SQL Setup cannot finish the CompleteImage action, as it is unable to look up some group names.  Running psGetSid on a group name returns a SID, then running psGetSid on that SID returns "LsaSetupDomain\groupname" instead of "COMPUTERNAME\groupname".

    Running with SetupType set to 0x02, SQL Setup completes successfully, and psGetSid returns COMPUTERNAME\groupname for any group lookups.  However the system does not reboot when the script completes.

    What I'm looking for is an explanation of how these values are used, and hopefully a way to get the behavior of 0x02 with a reboot after.

     

    Tuesday, November 09, 2010 9:37 PM

Answers

  • For HKLM\System\Setup!SetupType

    0=Do nothing, show login screen
    1=Run CMDLine then REBOOT
    2=Run CMDLine then show login screen

    So if you’re looking to have a reboot after running CMDLine use SetupType=2 to get the result you want from psGetSID

    But add this key too
    HKLM\System\Setup!SetupShutdownRequired=dword:00000001

    This will change the behavior of the SetupType to make the computer reboot after CMDLine

    Edit:
    Just some information for SetupShutdownRequired

    0=Shutdown Poweroff (Hard power off)
    1=Shutdown Reboot
    2=Shutdown NoReboot (Soft power off)


    • Proposed as answer by ZenShaze Wednesday, November 16, 2011 12:41 PM
    • Edited by ZenShaze Wednesday, November 16, 2011 1:58 PM
    • Marked as answer by Jason Walker 107 Wednesday, November 16, 2011 2:34 PM
    Wednesday, November 16, 2011 12:41 PM

All replies

  • Hi jwalker107, did you ever find an explanation for these keys? I'm using the values CmdLine and SetupType to deploy a BIOS update to Windows 7 x64 machines, the process runs in the context of system and the user is unable to interrupt, plus it's simple and using native Windows functionality. However I'd like to find some documentation as to what is possible with these keys. 

    HKEY_LOCAL_MACHINE\SYSTEM\Setup

    Friday, October 21, 2011 6:02 PM
  • No, I'm afraid I never did find any documentation or get any other responses here.  It appears we're both in undocumented territory though.

    I'm still using CmdLine with SetupType set to 0x2 to run the CompleteImage phase of SQL Express 2008 R2, on sysprep'd Windows XP clients as they are being deployed to the target systems.  Because it doesn't reboot on its own, I have a command running after the SQL CompleteImage phase that kills one of the required processes (LSASS.EXE, I think), which forces a reboot.

    If you find any more information, please, do post back here!

    Thanks much,
    Jason Walker

    Friday, October 21, 2011 8:22 PM
  • I should add that I did find a few (and only a few) references, and none were very clear on how this could/should be used by IT Pros.

    http://support.microsoft.com/kb/287506

    http://support.microsoft.com/kb/298491

    http://support.microsoft.com/kb/939857 (I found this on another board, but haven't been able to actually open the link.  Good luck!)

     

     

    • Proposed as answer by ZenShaze Wednesday, November 16, 2011 12:37 PM
    • Unproposed as answer by ZenShaze Wednesday, November 16, 2011 12:37 PM
    Friday, October 21, 2011 8:29 PM
  • For HKLM\System\Setup!SetupType

    0=Do nothing, show login screen
    1=Run CMDLine then REBOOT
    2=Run CMDLine then show login screen

    So if you’re looking to have a reboot after running CMDLine use SetupType=2 to get the result you want from psGetSID

    But add this key too
    HKLM\System\Setup!SetupShutdownRequired=dword:00000001

    This will change the behavior of the SetupType to make the computer reboot after CMDLine

    Edit:
    Just some information for SetupShutdownRequired

    0=Shutdown Poweroff (Hard power off)
    1=Shutdown Reboot
    2=Shutdown NoReboot (Soft power off)


    • Proposed as answer by ZenShaze Wednesday, November 16, 2011 12:41 PM
    • Edited by ZenShaze Wednesday, November 16, 2011 1:58 PM
    • Marked as answer by Jason Walker 107 Wednesday, November 16, 2011 2:34 PM
    Wednesday, November 16, 2011 12:41 PM
  • Thanks, that's most helpful!  I'll be trying it out later today.
    Wednesday, November 16, 2011 2:34 PM
  • So sorry I noticed I never replied back to this after testing.  Works beautifully.

     

    Under HKLM\System\Setup, I set

    CmdLine:REG_SZ:"c:\path\my_setup_script.cmd"

    SetupType:REG_DWORD:0x02

    --

    On next reboot, before the Windows Logon screen is displayed, a command window opens and executes my script.  Neither F8 nor Shift-F10 open a new window (good, my users can't elevate themselves while I'm doing this).  The script runs in SYSTEM context, and has access to the network and to network shares (provided the COMPUTER account has permissions on the share).  If the script is interrupted the window closes.

    While the script is running, I have it set the value at HKLM\System\Setup\SetupShutdownRequired:REG_DWORD:0x01, and when the script completes (or is interrupted) the system reboots normally.

    I've found that Windows will remove the value SetupShutdownRequired when it initiates the shutdown at the end, and will change the value of SetupType to 0 when it initiates the script.  I have some scripts that require multiple reboots, so I have to ensure these keys are set properly each time the script executes.

    Also, this works on both Windows XP x32 and Windows 7 x64.  Probably on others as well...after all I stumbled on this through looking at how Sysprep and Windows Mini-Setup operate.

    Hopefully this information will help someone out later (Hello, People of the Future!).  I've still found very little documentation on what seems a powerful installation feature.
    Wednesday, December 07, 2011 10:59 PM