Unattend.xml - FirstLogonCommands - Some won't run?

So!  I'm building something that requires creating unattend.xml files.  I'm getting bogged down in an issue with the FirstLogonCommands section.

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
  <settings pass="specialize">
    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <ComputerName>EXAM22</ComputerName>
      <TimeZone>Eastern Standard Time</TimeZone>
    </component>
  </settings>
  <settings pass="oobeSystem">
    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <UserAccounts>
        <AdministratorPassword>
          <Value>p@ssw0rd!</Value>
          <PlainText>true</PlainText>
        </AdministratorPassword>
      </UserAccounts>
      <AutoLogon>
        <Password>
          <Value>p@ssw0rd!</Value>
          <PlainText>true</PlainText>
        </Password>
        <Username>Administrator</Username>
        <LogonCount>1</LogonCount>
        <Enabled>true</Enabled>
      </AutoLogon>
      <FirstLogonCommands>
        <SynchronousCommand wcm:action="add">
          <Order>1</Order>
          <CommandLine>cmd.exe /c reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine>
          <Description>ChangeHideFiles</Description>
        </SynchronousCommand>
        <SynchronousCommand wcm:action="add">
          <Order>2</Order>
          <CommandLine>powershell.exe -noprofile -executionpolicy bypass -command "Set-Content C:\test 'WHATTHEHELL' -force"</CommandLine>
          <Description>PSell</Description>
        </SynchronousCommand>
      </FirstLogonCommands>
      <RegisteredOrganization>ORG</RegisteredOrganization>
      <RegisteredOwner>USER</RegisteredOwner>
      <OOBE>
        <HideEULAPage>true</HideEULAPage>
        <SkipMachineOOBE>true</SkipMachineOOBE>
      </OOBE>
    </component>
  </settings>
  <cpi:offlineImage cpi:source="" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

Everything above applies, apart from the FirstLogonCommands section.  For that, the registry change does not take effect, but the PowerShell command does.  Copying and pasting the registry change, it applies with no issue manually.  Have tried this with other syntax (e.g. C:\windows\system32\reg.exe ...).

What would cause that command to not run, while the other command, while the powershell command does run without issue?

Your insight would be greatly appreciated!

  • Changed type Cookie.Monster 8 hours 28 minutes ago No longer need the question answered...
March 16th, 2014 7:19pm

Have you validated script before using it?

M.

Free Windows Admin Tool Kit Click here and download it now
March 16th, 2014 8:31pm

I'm not sure what you mean.  To clarify, my issue is only with FirstLogonCommands.  Details:

  • The unattend.xml applies.
  • All the settings in it apply with no issue.
  • The FirstLogonCommands in the unattend.xml give me trouble
  • In the example I posted, the order=2 item, a small PowerShell snippet, runs without issue.
  • In the example I posted, the order=1 item, a registry change, does not run.  Copying and pasting the command line from this works without issue.  Changing from cmd.exe /c reg.exe ... to C:\windows\system32\reg.exe ... does not resolve the issue.

It's not particularly important, as I was just testing my unattend with the registry command, and any other commands can be inserted into a PowerShell script, which will apparently run without issue.  I'm just curious as to why the registry change didn't work.  And a bit miffed that I spent time troubleshooting it : )

March 16th, 2014 9:34pm

Hi,

Try this command directly:

<Order>1</Order>

      <CommandLine>reg ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f </CommandLine>

If this command still fails to run, check the setup log under %windir%\panther and windir%\panther\unattendGC.

Free Windows Admin Tool Kit Click here and download it now
March 17th, 2014 11:56am

No worries.  Can close this out.  A small part of a project I'm working on is an automated unattend.xml build via PowerShell that takes a number of parameters, including a hashtable that I translate into the FirstLogonCommands section.  The SynchronousCommand functionality is what I needed, and that appears to be working.

Whether there is some strange bug which prevents certain commands isn't in the scope of this school project : )

On a side note, I didn't try with your example, but this one does not execute either: <CommandLine>C:\windows\system32\reg.exe HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine>

Cheers!

March 17th, 2014 10:32pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics