none
Windows 7 unattended install first logon script

    Question

  • I've succeeded in capturing an image that does a completely unattended installation -- except activation. I have a script that uses C:\Windows\System32\Slmgr.vbs to activate Windows and I have that in the answers file as a first-logon.  However, it fails to run because it requires administrator priveleges.  How do I run a first-logon script as an administrator?

    Script:
      cscript C:\Windows\System32\Slmgr.vbs /ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx
      cscript C:\Windows\System32\Slmgr.vbs /skms xxx.xxx.xxx.xxx.xxx
      cscript C:\Windows\System32\Slmgr.vbs /ato
      pause

    When it is run, each of the first three commands says, "Access Denied: the requested action requires elevated priveleges"
    Tuesday, November 17, 2009 3:41 PM

Answers

  • Hi,

    Congragulations on your unattended image =)

    Rather than use first logon commands to activate Windows you could use SetupComplete.cmd (which runs after OOBE phase but before first logon) and place those commands in there. To do this create this file on the image: "%systemdrive%\Windows\Setup\Scripts\SetupComplete.cmd" and within that script put whatever commands you wish, in this case the 'slmgr.vbs' commands. 

    Note: Do NOT use the 'pause' command here in this script, as the script is run silently therefore you wont be able to escape from pause or for that matter accept user input from within the script either.

    Regards.
    • Marked as answer by puddingfox Wednesday, November 18, 2009 1:33 PM
    Wednesday, November 18, 2009 4:39 AM

All replies

  • Hi,

    Congragulations on your unattended image =)

    Rather than use first logon commands to activate Windows you could use SetupComplete.cmd (which runs after OOBE phase but before first logon) and place those commands in there. To do this create this file on the image: "%systemdrive%\Windows\Setup\Scripts\SetupComplete.cmd" and within that script put whatever commands you wish, in this case the 'slmgr.vbs' commands. 

    Note: Do NOT use the 'pause' command here in this script, as the script is run silently therefore you wont be able to escape from pause or for that matter accept user input from within the script either.

    Regards.
    • Marked as answer by puddingfox Wednesday, November 18, 2009 1:33 PM
    Wednesday, November 18, 2009 4:39 AM
  • That worked excellently. Thank you so much. I've been driving myself insane trying to make this answer file. For those interested, I'll post my answer file here:

    <?xml version='1.0' encoding='utf-8'?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
        <settings pass="specialize" wasPassProcessed="true">
            <component name="Microsoft-Windows-UnattendedJoin" 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">
                <Identification>
                    <Credentials>
                        <Domain>food.undernet.cs.odu.edu</Domain>
                        <Password>*SENSITIVE*DATA*DELETED*</Password>
                        <Username>james</Username>
                    </Credentials>
                    <JoinDomain>food.undernet.cs.odu.edu</JoinDomain>
                    <DebugJoin>true</DebugJoin>
                </Identification>
            </component>
            <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>*</ComputerName>
            </component>
        </settings>
        <settings pass="windowsPE">
            <component name="Microsoft-Windows-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">
                <DiskConfiguration>
                    <Disk wcm:action="add">
                        <CreatePartitions>
                            <CreatePartition wcm:action="add">
                                <Order>1</Order>
                                <Size>300</Size>
                                <Type>Primary</Type>
                            </CreatePartition>
                            <CreatePartition wcm:action="add">
                                <Extend>true</Extend>
                                <Order>2</Order>
                                <Type>Primary</Type>
                            </CreatePartition>
                        </CreatePartitions>
                        <ModifyPartitions>
                            <ModifyPartition wcm:action="modify">
                                <Active>true</Active>
                                <Format>NTFS</Format>
                                <Label>System</Label>
                                <Order>1</Order>
                                <PartitionID>1</PartitionID>
                            </ModifyPartition>
                            <ModifyPartition wcm:action="modify">
                                <Format>NTFS</Format>
                                <Order>2</Order>
                                <PartitionID>2</PartitionID>
                                <Extend>true</Extend>
                            </ModifyPartition>
                        </ModifyPartitions>
                        <WillWipeDisk>true</WillWipeDisk>
                        <DiskID>0</DiskID>
                    </Disk>
                    <WillShowUI>OnError</WillShowUI>
                </DiskConfiguration>
                <ImageInstall>
                    <OSImage>
                        <InstallTo>
                            <DiskID>0</DiskID>
                            <PartitionID>2</PartitionID>
                        </InstallTo>
                        <WillShowUI>OnError</WillShowUI>
                        <InstallToAvailablePartition>false</InstallToAvailablePartition>
                    </OSImage>
                </ImageInstall>
                <UserData>
                    <ProductKey>
                        <Key>*blah*</Key>
                        <WillShowUI>OnError</WillShowUI>
                    </ProductKey>
                    <AcceptEula>true</AcceptEula>
                    <FullName>*blah*</FullName>
                    <Organization>Old Dominion University Computer Science</Organization>
                </UserData>
                <Display>
                    <HorizontalResolution>1024</HorizontalResolution>
                    <VerticalResolution>768</VerticalResolution>
                </Display>
            </component>
            <component name="Microsoft-Windows-International-Core-WinPE" 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">
                <SetupUILanguage>
                    <UILanguage>en-us</UILanguage>
                </SetupUILanguage>
                <InputLocale>en-us</InputLocale>
                <SystemLocale>en-us</SystemLocale>
                <UILanguage>en-us</UILanguage>
                <UserLocale>en-us</UserLocale>
            </component>
        </settings>
        <settings pass="oobeSystem" wasPassProcessed="true">
            <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">
                <OOBE>
                    <HideEULAPage>true</HideEULAPage>
                    <ProtectYourPC>1</ProtectYourPC>
                    <NetworkLocation>Work</NetworkLocation>
                </OOBE>
                <Display>
                    <HorizontalResolution>1024</HorizontalResolution>
                    <VerticalResolution>768</VerticalResolution>
                </Display>
                <UserAccounts>
                    <AdministratorPassword>*SENSITIVE*DATA*DELETED*</AdministratorPassword>
                    <LocalAccounts>
                        <LocalAccount wcm:action="add">
                            <Password>*SENSITIVE*DATA*DELETED*</Password>
                            <Name>James</Name>
                            <Group>Administrators</Group>
                        </LocalAccount>
                    </LocalAccounts>
                </UserAccounts>
                <TimeZone>eastern standard time</TimeZone>
            </component>
            <component name="Microsoft-Windows-International-Core" 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">
                <UserLocale>en-us</UserLocale>
                <UILanguageFallback>en-us</UILanguageFallback>
                <SystemLocale>en-us</SystemLocale>
                <InputLocale>en-us</InputLocale>
                <UILanguage>en-us</UILanguage>
            </component>
        </settings>
        <cpi:offlineImage cpi:source="wim:d:/sources/install.wim#Windows 7 ENTERPRISE" xmlns:cpi="urn:schemas-microsoft-com:cpi"></cpi:offlineImage>
    </unattend>
    Wednesday, November 18, 2009 1:36 PM
  • Could any one please just tell me if im doing this correct?

     

    I have used my own .xml file like the one above but it all fails.

    Where should I be placing the .xml file and when should i run? either in the sysprep /oobe /shutdown /unattend:unattend.xml or do i push it out with the wim file when i do a multi cast?

     

    Thankyou

     

     

     

    Wednesday, August 04, 2010 11:00 AM
  • Hi Anjay,

    Please create a new thread with your question in it.

    Your answer file should be on the partition that Windows is on which you are "syspreping".

    ie: C:\Windows\System32\sysprep\sysprep /oobe /shutdown /unattend:C:\unattend.xml

    Regards.

    Wednesday, August 04, 2010 11:17 AM
  • I have a question along these lines. I able to capture a win7 pro image, that I manually create, capture, using imagex, MDT.  I have been trying to figure out how to edit the Task Sequence, Unattend.xml in SIM to avoid creating a new logon, everytime a deployment disk is run;  when it should go directly to the builtin account when the image was created.  I have to deploy images by Disk alone. HELP
    Thursday, April 05, 2012 2:25 PM
  • I believe I had a similar issue when I made my unattend.xml file. What I did was input a Temp name for the local account section in the unattend file then ran a small script as a first logon command to delete the temp account.

    FIRST in the unattend file..

    <LocalAccounts>
                        <LocalAccount wcm:action="add">
                            <Password>
                                <Value>MYPASSWORD</Value>
                                <PlainText>false</PlainText>
                            </Password>
                            <Description>Temp</Description>
                            <DisplayName>Temp</DisplayName>
                            <Group>Administrators</Group>
                            <Name>Temp</Name>
                        </LocalAccount>
                    </LocalAccounts>
                </UserAccounts>

    THEN the VBS script to delete the temp account at first logon..

    Set oAccount = GetObject("WinNT://.")
    oAccount.Delete "user", "Temp"

    NOTE: you will have to have the full path in the Command Line section of the FirstLogonCommand in order for it to run. It does not automatically look in the same location as the unattend file.

    • Proposed as answer by TechClinton Monday, April 09, 2012 3:09 PM
    Monday, April 09, 2012 3:01 PM
  • Thank you your reply,  I'm going to try this after I figure out full path for the command line. I'll let you all know how it goes.
    Wednesday, April 11, 2012 8:48 PM
  • The solution is not to generalize your custom image during the Sysprep phase, however you do need to specify in your unattended file to load locally created workgroup or domain account with password. I only used workgroup with password. Installation will logon once directly into the account specified in the unattend.xml  and run action to clean up the temp account and deletes it.

    Tuesday, June 19, 2012 5:54 PM