Create media for automated unattended install of Windows 10  

Page 40 of 99 FirstFirst ... 3038394041425090 ... LastLast

  1. Posts : 4,187
    Windows 11 Pro, 22H2
       #390

    I wanted to share a batch file that I have created that works along with the steps in Kari's tutorial.

    This batch file has the following options:

    1) Perform Windows customizations.
    2) Deploy your assets for sysprep (refer to section 5 of Kari's tutorial) and then perform the actual sysprep.

    You can perform either one of the above operations individually or have the batch file run them both, one after the other.

    The intention of this batch file is to help with the customization tasks that you will perform once you are booted into audit mode (see part 7 of the tutorial).

    I created the batch file because I was always performing a lot of the same customizations to every reference system I was creating and I wanted to automate all those changes. Today I decided to just extend the functionality a bit more.

    1) Perform Windows customizations.

    You can easily add to remove from what the batch file does, use it as a framework. Currently it will perform the following Windows customizations:

    A) Disable "annoying" Windows features
    Change how often Windows asks you for feedback to "NEVER"
    Disable feedback notifications
    Disable "Get tips, tricks, and suggestions as you use Windows"
    Disable the Windows welcome experience
    Disable app suggestions in start
    Disable display of suggested content in settings
    Turn off tailored experiences with diagnostic data
    Turn off suggestions in timeline
    Disable Tips, Tricks, and Suggestions

    B) Tweak some general Windows settings
    Increase the desktop icon spacing slightly
    Modify Screen Saver Password Grace Period
    Display seconds on the taskbar clock
    Auto hide the taskbar in desktop mode
    Allow the master volume control to adjust bluetooth volume (optional, batch file asks if you want to do this)
    Allow lock screen timeout to be changed (optional, batch file asks if you want to do this)

    C) File explorer customizations
    Turn on Expand to current folder
    Turn on Show all folders
    Turn on Show Libraries
    Display full path in the title bar
    Show empty drives
    Show file name extensions
    Show encrypted and compressed files in color
    Show hidden files folders and drives (not system files)
    Use check boxes to select items
    Disable the sharing wizard
    Launch File Explorer to "This PC"

    D) Other settings
    Set Taskbar Combining to "Always combine, hide labels"
    Disable Standby Timeout on Both AC and DC Power
    Apply a customized themepack to Windows

    NOTES: Disabling Standby timeout can be very handy on your reference system. If the default timeout occurs, you cannot log back on again while in Audit mode unless you forcibly stop / restart the system so this setting will save you from that.

    When a customized themepack is applied, the Settings app is automatically opened. This is normal. You can close it if you want, but it's not necessary.

    After the Windows customizations are applied, the system is automatically rebooted, unless you choose to also perform sysprep. In that case, assets are prepared for sysprep after the customizations are made, sysprep is run, and the system will shutdown.

    IMPORTANT: After sysprep is run, don't let the reference system boot normally. You want to interrupt boot and boot from alternate media as Kari's tutorial instructs so that you can create an image.

    2) Prep for sysprep / execute sysprep

    This part of the batch file will copy the assets to the correct locations, create the C:\Image and C:\Scratch directories for the purpose of creating the final image, and finally performs the actual sysprep operation.

    How to Use the Batch File

    Follow the tutorial until you reach section 7 at which point you are performing your Windows customizations.

    Copy the following files to the desktop of the Reference system:

    The batch file
    Any custom themepacks
    Oemlogo.bmp (if you are using one)
    Autounattend.xml
    Unattend.xml
    Any software installers

    NOTE: RunOnce.bat is not needed, the batch file creates it on the fly.

    As noted above, the functions to prepare assets for sysprep and then run it, and the option to make Windows customizations are separated so that you don't have to run them at the same time. For example, I like to apply my Windows customizations first. That way, everything is setup how I like right away. I can now install all my apps with all the Windows customization already done.

    Once I have all my apps installed, I run the batch file again and choose the option to perform sysprep.

    Suggestion: If your reference system is a VM, you might want to take a snapshot before running the batch file the first time to get familiar with it. With a snapshot, you can go back, just in case you need to do so.

    Code:
    REM Configure a few initial settings
    
    @echo off
    setlocal enabledelayedexpansion
    setlocal enableextensions
    cd /d %~dp0
    
    REM Check to see if this batch file is being run as Administrator
    
    openfiles > NUL 2>&1 
    if NOT %ERRORLEVEL% EQU 0 goto NotAdmin 
    goto IsAdmin
    
    :NotAdmin
    
    REM The batch file was not run as admin. Launch a new copy of the batch file as admin and close the current instance.
    
    powershell.exe start-process '%~f0' -verb runas
    exit
    
    :IsAdmin
    
    REM If we arrive here, then the batch file is being run elevated.
    REM End Routine to check if being run as Admin
    
    cls
    echo Which do you want to do?
    echo.
    echo 1) Apply Windows customizations
    echo 2) Get everything ready for sysprep and then run sysprep
    echo 3) Both of the above
    echo 4) Quit
    echo.
    choice /c 1234 /m "Please make a selection: "
    
    IF ERRORLEVEL 4 goto END
    IF ERRORLEVEL 3 (
    set DoBoth=Y
    goto Customize
    )
    IF ERRORLEVEL 2 goto RunSysprep
    IF ERRORLEVEL 1 (
    set DoBoth=N        
    goto Customize
    )
    
    :Customize
    
    REM Ask the user if they want to modify bluetooth settings.
    REM The text below explains exactly what this Windows tweak does.
    
    cls
    echo For some bluetooth audio devices devices, changing the master volume in Windows may not cause the volume of the
    echo device to change. Do you want to apply a tweak that will change this behavior?
    echo.
    choice /M "Update bluetooth behavior "
    IF ERRORLEVEL==1 (
       SET UpdateBluetooth=Y
    )
    IF ERRORLEVEL==2 (
       SET UpdateBluetooth=N
    )
    
    cls
    echo By default, the lockscreen will transition to a blank screen after one minute. If you want to be able to display
    echo a screensaver for a period of time, this functionality will interfere with this. Do you want to make a change that
    echo will allow you to work around this?
    echo.
    choice /M "Update lockscreen behavior "
    IF ERRORLEVEL==1 (
       SET UpdateLockscreen=Y
    )
    
    IF ERRORLEVEL==2 (
       SET UpdateLockscreen=N
    )
    
    REM       ******************************************************
    REM       * Change the behavior of annoying Windows "features" *
    REM       ******************************************************
    
    REM *************************************************************
    REM * Change how often Windows asks you for feedback to "NEVER" *
    REM *************************************************************
    
    REG ADD HKCU\SOFTWARE\Microsoft\Siuf\Rules /v NumberOfSIUFInPeriod /t REG_DWORD /d 0x00000000 /f > NUL
    REG DELETE "HKCU\SOFTWARE\Microsoft\Siuf\Rules" /v PeriodInNanoSeconds /f > NUL 2>&1
    
    REM **********************************
    REM * Disable feedback notifications *
    REM **********************************
    
    REG ADD HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection /v DoNotShowFeedbackNotifications /t REG_DWORD /d 0x00000001 /f > NUL
    
    REM ******************************************************************
    REM * Disable "Get tips, tricks, and suggestions as you use Windows" *
    REM ******************************************************************
    
    REG ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SubscribedContent-338389Enabled /t REG_DWORD /d 0x00000000 /f > NUL
    
    REM ******************************************
    REM * Disable the Windows welcome experience *
    REM ******************************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SubscribedContent-310093Enabled /t REG_DWORD /d 0x00000000 /f > NUL
    
    REM ************************************
    REM * Disable app suggestions in start *
    REM ************************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SubscribedContent-338388Enabled /t REG_DWORD /d 0x00000000 /f > NUL
    
    REM ****************************************************
    REM * Disable display of suggested content in settings *
    REM ****************************************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SubscribedContent-338393Enabled /t REG_DWORD /d 0x00000000 /f > NUL
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SubscribedContent-353694Enabled /t REG_DWORD /d 0x00000000 /f > NUL
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SubscribedContent-353696Enabled /t REG_DWORD /d 0x00000000 /f > NUL
    
    REM ******************************************************
    REM * Turn off tailored experiences with diagnostic data *
    REM ******************************************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Privacy /v TailoredExperiencesWithDiagnosticDataEnabled /t REG_DWORD /d 0x00000000 /f > NUL
    
    REM ************************************
    REM * Turn off suggestions in timeline *
    REM ************************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SubscribedContent-353698Enabled /t REG_DWORD /d 0x00000000 /f > NUL
    
    REM *****************************************
    REM * Disable Tips, Tricks, and Suggestions *
    REM *****************************************
    
    REG ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SubscribedContent-338389Enabled /t REG_DWORD /d 0x00000000 /f > NUL
    
    REM       *******************************
    REM       * Tweak some general settings *
    REM       *******************************
    
    REM **********************************************
    REM * Increase the desktop icon spacing slightly *
    REM **********************************************
    
    REM Default setting for "IconSpacing" is -1125, for "IconVerticalSpacing"
    REM the default is also 1125.
    
    REM Set these settings to (-15 * horizontal spacing between icons in pixels)
    REM The below settings have been tested on the HP Spectre x360 BL012DX Laptop Computer.
    
    REM For the change to take effect, after making the registry change, do one of the following:
    
    REM 1) Sign out from your user account and then sign back in.
    REM 2) Right-click the desktop, uncheck "Align icons to grid", then re-check it.
    
    REM Since this batch file will perform a reboot, you won't need to do either of the above.
    
    REG ADD "HKCU\Control Panel\Desktop\WindowMetrics" /v IconSpacing /d -1500 /f > NUL
    REG ADD "HKCU\Control Panel\Desktop\WindowMetrics" /v IconVerticalSpacing /d -1200 /f > NUL
    
    REM *********************************************
    REM * Modify Screen Saver Password Grace Period *
    REM *********************************************
    
    REM When password protection for your screen saver is enabled, by default there is a 5 second grace period before
    REM you must enter a password. This registry setting will modify that grace period. Valid values are from 0 to 2147483.
    REM To restore the default, delete "ScreenSaverGracePeriod" value.
    
    REM Note that this entry is specified in hexadecimal.
    
    REM This REG file is currently configured to set the grace period to 15 seconds.
    
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v ScreenSaverGracePeriod /t REG_DWORD /d 0x0000000f /f > NUL
    
    REM ****************************************
    REM * Display seconds on the taskbar clock *
    REM ****************************************
    
    REM This will cause the clock on the taskbar to show seconds. Windows Explorer needs to be restarted
    REM before this will take effect.
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowSecondsInSystemClock /t REG_DWORD /d 0x00000001 /f > NUL
    
    REM *****************************************
    REM * Auto hide the taskbar in desktop mode *
    REM *****************************************
    
    REM The setting for the taskbar is inside a long string of hex data. There are 48 octets in total.
    REM The 9th octet (17th and 18th characters) are "02" when autohide is disabled, "03" when enabled.
    REM In order to avoid changing the rest of the data we are going to read the data, then change
    REM only the 9th octet, and finally write this back to the registry.
    
    REM Begin by saving the registry key to a temporary file.
    
    REG QUERY HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3 /v Settings > reg_temp.txt
    
    REM Get the second line of the output from the temporary file.
    
    for /F "skip=1 delims=" %%i in (reg_temp.txt) do (
    set LineContents=%%i
    )
    
    REM We no longer need the temp file, delete it.
    
    del reg_temp.txt
    
    REM Parse the line that we just captured. The goal here is to keep the first 16 charcters, replace the next 2
    REM characters with "03", and then keep the remaining characters. Since the string is 96 characters long, 
    REM (48 octets), we will grab the first 16 characters starting with the 96th character from the end, then insert
    REM the "03", and finally add the last 78 characters.
    
    set LineContentsP1=!LineContents:~-96,16!
    set LineContentsP2=!LineContents:~-78!
    set LineContents=%LineContentsP1%03%LineContentsP2%
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3 /v Settings /t REG_BINARY /d %LineContents% /f > NUL
    
    REM **************************************************************
    REM * Allow the master volume control to adjust bluetooth volume *
    REM **************************************************************
    
    REM For some devices, the master volume may not alter the volume of a bluetooth device. Example: Edifier speakers connected via bluetooth.
    REM Changing the setting below from 0 to 1 should resolve this.
    REM To revert back, run the REG ADD command below with a "/d 0x00000000".
    
    if %UpdateBluetooth%==Y (
    REG ADD HKLM\SYSTEM\ControlSet001\Control\Bluetooth\Audio\AVRCP\CT /v DisableAbsoluteVolume /t REG_DWORD /d 0x00000001 /f > NUL
    )
    
    REM *******************************************
    REM * Allow lock screen timeout to be changed *
    REM *******************************************
    
    REM This registry entry enables a new setting in the Advanced settings of the Power Options Control Panel app.
    REM The user will still need to set the timeout in that app. After we make the change to the registry, we
    REM will open that app to allow the user to make the change.
    
    IF %UpdateLockscreen%==Y (
    REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\7516b95f-f776-4464-8c53-06167f40cc99\8EC4B3A5-6868-48c2-BE75-4F3044BE88A7 /v attributes /t REG_DWORD /d 0x00000002 /f > NUL
    cls
    echo The registry has been modified to allow the lock screen timeout to be changed. We are now opening the Advanced Power
    echo Settings from the Control Panel Power Options utility to allow you to set a lock screen timeout. Select the
    echo "Display > Console lock display off timeout" setting to change the timeout.
    echo.
    echo Dont press any key while focus is on this batch file until you are done setting that option.
    echo.
    control powercfg.cpl,,1,
    pause
    )
    
    REM       ********************************
    REM       * File Explorer Customizations *
    REM       ********************************
    
    REM ************************************
    REM * Turn on Expand to current folder *
    REM * Turn on Show all folders         *
    REM ************************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v NavPaneExpandToCurrentFolder /t REG_DWORD /d 0x00000001 /f > NUL
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v NavPaneShowAllFolders /t REG_DWORD /d 0x00000001 /f > NUL
    
    REM **************************
    REM * Turn on Show Libraries *
    REM **************************
    
    REG ADD HKCU\Software\Classes\CLSID\{031E4825-7B94-4dc3-B131-E946B44C8DD5} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0x00000001 /f > NUL
    
    REM **************************************
    REM * Display full path in the title bar *
    REM **************************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState /v FullPath /t REG_DWORD /d 0x00000001 /f > NUL
    
    REM *********************
    REM * Show empty drives *
    REM *********************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideDrivesWithNoMedia /t REG_DWORD /d 0x00000000 /f > NUL
    REG DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideDrivesWithNoMedia /f > NUL 2>&1
    
    REM *****************************
    REM * Show file name extensions *
    REM *****************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0x00000000 /f > NUL
    
    REM ************************************************
    REM * Show encrypted and compressed files in color *
    REM ************************************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowEncryptCompressedColor /t REG_DWORD /d 0x00000001 /f > NUL
    
    REM ****************************************
    REM * Show hidden files folders and drives *
    REM ****************************************
    
    REG ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 0x00000001 /f > NUL
    
    REM ***********************************
    REM * Use check boxes to select items *
    REM ***********************************
    
    REG ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v AutoCheckSelect /t REG_DWORD /d 0x00000001 /f > NUL
    
    REM ******************************
    REM * Disable the sharing wizard *
    REM ******************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v SharingWizardOn /t REG_DWORD /d 0x00000000 /f > NUL
    
    REM ***********************************
    REM * Launch File Explorer to This PC *
    REM ***********************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v LaunchTo /t REG_DWORD /d 0x00000001 /f > NUL
    
    REM       ************************
    REM       * Other Customizations *
    REM       ************************
    
    REM **********************************************************
    REM * Set Taskbar Combining to "Always combine, hide labels" *
    REM **********************************************************
    
    REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v TaskbarGlomLevel /t REG_DWORD /d 0x00000000 /f > NUL
    
    REM ***************************************************
    REM * Disable Standby Timeout on Both AC and DC Power *
    REM ***************************************************
    
    powercfg -change -standby-timeout-dc 0
    powercfg -change -standby-timeout-ac 0
    
    REM ******************************************************
    REM * Apply a customized themepack to Windows. Note that *
    REM * the themepack should be located in the same folder *
    REM * where this program is run from.                    *
    REM ******************************************************
    
    MyCustomTheme.deskthemepack
    del MyCustomTheme.deskthemepack > NUL
    
    REM All settings have been applied. Even though we are restarting, for some reason the setting to auto hide the taskbar requires that
    REM File explorer.exe be restarted. If you don't restart it, that registry setting will revert back, even after a logoff / logon or reboot.
    REM As a result, we will restart explorer.exe first, then reboot the system.
    
    REM Restart explorer
    
    taskkill /f /im explorer.exe
    start explorer.exe
    
    REM *********************************
    REM * END OF WINDOWS CUSTOMIZATIONS *
    REM *********************************
    
    if %DoBoth%==N goto Reboot
    
    :RunSysprep
    
    cls
    echo Getting everything ready for sysprep...
    echo Running sysprep...
    echo.
    
    REM The following lines place the oemlogo.bmp, unattend.xml, and autounattend.xml files in the correct locations.
    REM It also creates the C:\Image and C:\Scratch folders used for creating the the final image files. Finally,
    REM it generates a RunOnce.bat file.
    
    move /Y oemlogo.bmp %windir%\system32 > NUL
    move /Y unattend.xml %windir%\system32\sysprep > NUL
    move /Y autounattend.xml %systemdrive%\ > NUL
    md c:\Image > NUL
    md c:\Scratch > NUL
    
    REM Create a "RunOnce.bat" file and place it.
    REM NOTE: I have modified the RunOnce file just slightly from Kari's instructions. I like to have the RunOnce automatically
    REM log me off after the first logon. This works especially well if you implement a one time autologon for 100% fully
    REM unattended installation, but it is optional. If you don't want this, simply remove the "^& logoff" from the 2nd line below.
    
    echo echo Y ^| del %%appdata%%\microsoft\windows\recent\automaticdestinations\* > "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\RunOnce.bat"
    echo del %%0 ^& logoff >> "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\RunOnce.bat"
    
    del %0 & %windir%\System32\Sysprep\sysprep.exe /generalize /oobe
    
    REM We should never reach this line, it is here just to be on the safe side
    goto END
    
    :Reboot
    
    REM Reboot the system
    shutdown /r /t 0
    
    :END
    Please feel free to let me know if you have any questions.

    EDIT:

    A situation just dawned on me that you may want to be aware of:


    IMPORTANT: MAKE SURE that you make any personalization settings changes BEFORE the network is enabled. After enabling networking, personalization settings cannot be made until Windows is activated.

    NOTE: The ability to make personalization setting changes does not work if you install Windows in Hyper-V! Even with no network access, personalization will not be possible. The changes made by this batch file should still work, although I have not verified each and every one on Hyper-V. If you want to perform personalization for a reference system on Hyper-V, you have a few options:


    • You can activate Windows in Audit mode by allowing access to the Internet.
    • You can import a themepack which will allow very limited personalization.
    • Perform the following procedure as a workaround:


    *********************************
    * Start of Workaround Procedure *
    *********************************

    Overview:


    • Create a Virtual Hard Disk (VHD) in Windows.
    • Deploy Windows to it.
    • Boot the physical machine to that VHD and setup Windows.
    • Perform your personalization tasks.
    • Create a new Hyper-V VM and configure the VHD to boot from that VM.



    Here are detailed steps for accomplishing this:


    1. Create either an MBR VHD for a BIOS based system or a GPT VHD for a UEFI based system


    NOTE: The commands below assume you are creating the VHD on F:, that you want to call it WIN10PRO.vhdx, that you want a size of 50GB, and that you want to assign the drive letter W: to the VHD. Modify to fit your needs.

    To create an MBR virtual disk for a BIOS based system:

    create vdisk file=F:\W10PRO.vhdx maximum=51200 type=expandable
    attach vdisk
    create partition primary
    format quick label="Windows"
    assign letter=W
    exit

    OR

    To create a GPT Virtual disk for a UEFI based system:

    create vdisk file=F:\W10PRO.vhdx maximum=51200 type=expandable
    attach vdisk
    convert gpt
    create partition efi size=100
    format quick fs=fat32 label="System"
    create partition msr size=128
    create partition primary
    shrink minimum=500
    format quick fs=ntfs label="Windows"
    assign letter="W"
    create partition primary
    format quick fs=ntfs label="WinRE"
    set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    exit

    IMPORTANT: Due to FAT32 limitations, the minimum FAT32 partition size is 260 MB on Advanced Format 4K Native drives. As a result, make the EFI partition 260 MB on such drives rather than 100 MB.

    2) Run the following commands to apply the image to the VHD:

    NOTE: If C: (the drive on which Windows is installed) is bitlocker encrypted, suspend bitlocker from the GUI or run manage-bde -protectors -disable C: before you run the bcdboot and bcdedit commands below to avoid having to enter your bitlocker recovery key at start. You need to create the VHD on a disk other than the bitlocker encrypted Windows disk. NOTE: The first line is long and wraps in this document. It ends with /applydir:W:\. You can replace W: with another drive letter.

    dism /apply-image /imagefile:I:\sources\install.wim /index:8 /applydir:W:\
    bcdboot W:\Windows
    bcdedit /set {default} description "Win10 PRO (VHD)"

    3) To delete the boot entry for the VHD, run MSCONFIG, go to the Boot tab, delete the entry for the VHD boot, and optionally delete the VHD. Note that if C: (the Windows boot disk) is bitlocker encrypted you should suspend bitlocker from the GUI or run manage-bde -protectors -disable C: first.

    4) If you want to attach the VHD to Hyper-V and boot from it, you must create boot files on the VHD disk like this:


    • Boot the new VM from Windows install media (an ISO image).
    • Run diskpart
    • Within diskpart, run list vol
    • Note the drive letter for the Windows partition (for example, C:)
    • exit from diskpart
    • run this command: C:\Windows\System32\bcdboot C:\Windows - This assumes Windows is on C:


    *******************************
    * End of Workaround Procedure *
    *******************************
    Last edited by hsehestedt; 16 Jun 2020 at 03:04.
      My Computers


  2. Posts : 25
    Windows 10 Enterprise LTSC 21H1
       #391

    hsehestedt said:
    I wanted to share a batch file that I have created that works along with the steps in Kari's tutorial.
    Hi Dear friend @hsehestedt,

    Is possible that you made a video preview of your process?

    Thanks in advanced.

    Best Regards,
    @JeepWillys58
      My Computer


  3. Posts : 4,187
    Windows 11 Pro, 22H2
       #392

    JeepWillys58 said:
    Hi Dear friend @hsehestedt,

    Is possible that you made a video preview of your process?
    I have not made a video yet. But it would be easy enough to make one. Was there something in particular you wanted to see?
      My Computers


  4. Posts : 4,187
    Windows 11 Pro, 22H2
       #393

    As requested, the link below will take you to a video showing the batch file in use.

    Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.
      My Computers


  5. Posts : 25
    Windows 10 Enterprise LTSC 21H1
       #394

    hsehestedt said:
    I have not made a video yet. But it would be easy enough to make one. Was there something in particular you wanted to see?
    Hello again Dear friend @hsehestedt,

    I'm sorry for just answering now, but I just got home ...

    Could you tell me if before using this batch I can install any application, like office 2019 and also windows updates?

    And of course, grateful for your efforts in making the video of using the batch, I tried to click on "Thanks", but as I'm new here, the following message appears to me:
    "You must spread some Reputation around before giving it to hsehestedt again."

    Thanks in advanced.

    Regards @JeepWillys58
      My Computer


  6. Posts : 4,187
    Windows 11 Pro, 22H2
       #395

    JeepWillys58 said:
    Hello again Dear friend @hsehestedt,
    Could you tell me if before using this batch I can install any application, like office 2019 and also windows updates?
    @JeepWillys58
    Absolutely, you can install your apps and Windows updates.

    If I may, let me just give you a few suggestions:

    1) Try following the steps of Kari's tutorial precisely as they are the first couple of times that you do this. It will help you to become familiar with the whole process and the tutorial has been tried and proven to work by many users here.

    2) Once you are familiar with the whole process, then you can try some timesaving steps such as the batch file.

    3) You will find this detailed in the tutorial, but just to reiterate it here, the time for installing updates, apps, etc. is once you are booted into audit mode. Just a couple of reminders: Perform your personalization tasks before you enable networking. You can reboot as often as you need, just make sure to cancel the screen about sysprep that comes up each time when you restart.

    4) If you are using the batch file, you can either install all your apps and Windows updates before you run the batch file option #1 or after. My suggestion would be to run the batch file option #1 first since that does the personalization tasks. After that you can enable networking and install all yur apps and Windows updates. Finally, you would run the batch file again but this time you would choose the option to perform the actual sysprep.

    BTW, thanks for rep. It's much appreciated.

    If you have any questions as you progress through this, just let us know
      My Computers


  7. Posts : 25
    Windows 10 Enterprise LTSC 21H1
       #396

    hsehestedt said:
    Absolutely, you can install your apps and Windows updates.

    If I may, let me just give you a few suggestions:

    1) Try following the steps of Kari's tutorial precisely as they are the first couple of times that you do this. It will help you to become familiar with the whole process and the tutorial has been tried and proven to work by many users here.

    2) Once you are familiar with the whole process, then you can try some timesaving steps such as the batch file.

    3) You will find this detailed in the tutorial, but just to reiterate it here, the time for installing updates, apps, etc. is once you are booted into audit mode. Just a couple of reminders: Perform your personalization tasks before you enable networking. You can reboot as often as you need, just make sure to cancel the screen about sysprep that comes up each time when you restart.

    4) If you are using the batch file, you can either install all your apps and Windows updates before you run the batch file option #1 or after. My suggestion would be to run the batch file option #1 first since that does the personalization tasks. After that you can enable networking and install all yur apps and Windows updates. Finally, you would run the batch file again but this time you would choose the option to perform the actual sysprep.

    BTW, thanks for rep. It's much appreciated.

    If you have any questions as you progress through this, just let us know
    Hi again dear friend @hsehestedt

    Thank you for all this information my friend.

    Before watching this tutorial, I already did something like this, and after installing the customizations, software and updates in audit mode, I used this a batch and a script to relocate the user profile folder:

    AdminSysprepCommands.cmd
    Code:
    net stop wmpnetworksvc
    
    net stop wmpnetworksvc
    
    %windir%\system32\sysprep\sysprep.exe /oobe /reboot /unattend:D:\MoveUsersFolder\MoveUsersFolder.xml
    MoveUsersFolder.xml
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
    <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">
    <FolderLocations>
    <ProfilesDirectory>D:\UserProfiles</ProfilesDirectory>
    </FolderLocations>
    </component>
    </settings>
    </unattend>
    Now I will try to do it using the steps of our dear friend @Kari, but I still have only one question regarding the modification I made to my unattend.xml, adding the <FolderLocations> variable, because I changed the location of the user profiles folder to volume "D: " this process will not compromise the settings of the sysprep?

    I leave the copy of my unattend.xml file in full for you to view and give your opinion on this change and its consequences.

    unattend.xml
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
        <settings pass="oobeSystem">
            <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">
                <InputLocale>0416:00000416</InputLocale>
                <SystemLocale>pt-BR</SystemLocale>
                <UILanguage>pt-BR</UILanguage>
                <UILanguageFallback>pt-BR</UILanguageFallback>
                <UserLocale>pt-BR</UserLocale>
            </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">
                <OOBE>
                    <HideEULAPage>true</HideEULAPage>
                    <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
                    <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
                    <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
                    <ProtectYourPC>1</ProtectYourPC>
                    <UnattendEnableRetailDemo>false</UnattendEnableRetailDemo>
                </OOBE>
                <UserAccounts>
                    <LocalAccounts>
                        <LocalAccount wcm:action="add">
                            <Password>
                                <Value>VwBTAEkATQBfAFUAbgBpAHYAZQByAHMAYQBsAFAAYQBzAHMAQABkAG0ALQBTAFMASQArADIAMAAyADAAKgBQAGEAcwBzAHcAbwByAGQA</Value>
                                <PlainText>false</PlainText>
                            </Password>
                            <Description>Conta Principal de Administrador Local Universal</Description>
                            <DisplayName>Administrador Local Universal</DisplayName>
                            <Name>UniversalLocalAdmin</Name>
                            <Group>Administradores</Group>
                        </LocalAccount>
                    </LocalAccounts>
                </UserAccounts>
                <RegisteredOrganization>Microsoft Corporation</RegisteredOrganization>
                <RegisteredOwner>Microsoft Corporation</RegisteredOwner>
                <TimeZone>E. South America Standard Time</TimeZone>
                <FolderLocations>
                    <ProfilesDirectory>D:\UserProfiles</ProfilesDirectory>
                </FolderLocations>
            </component>
        </settings>
        <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">
                <OEMInformation>
                    <Logo>\windows\SoftwareDistribution\OEM\OEMLogoSS.bmp</Logo>
                    <Manufacturer>SS.</Manufacturer>
                    <SupportURL>https://www.SS.com/contacts/</SupportURL>
                    <SupportHours>Segunda ą Sexta: 08:00 ąs 19:00</SupportHours>
                    <SupportPhone>(XX) XXXXX-XXXX</SupportPhone>
                </OEMInformation>
                <CopyProfile>true</CopyProfile>
                <ComputerName>SSDESKTOP</ComputerName>
                <TimeZone>E. South America Standard Time</TimeZone>
                <OEMName>Microsoft Corporation</OEMName>
                <RegisteredOrganization>Microsoft Corporation</RegisteredOrganization>
                <RegisteredOwner>Microsoft Corporation</RegisteredOwner>
            </component>
        </settings>
        <cpi:offlineImage cpi:source="wim:d:/windowsimagingconfigurationdesigner/iso_files/sources/install.wim#Windows 10 Enterprise" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    One more time, thanks in advanced for your help.

    Best Regards

    @JeepWillys58
      My Computer


  8. Posts : 4,187
    Windows 11 Pro, 22H2
       #397

    @JeepWillys58,

    I must admit that I have no personal experience moving user profiles so I would defer to Kari's comments on the matter.

    I know that you saw Kari's post on the topic here:

    Create media for automated unattended install of Windows 10

    Please make sure to look at the tutorial he links to in that post (Move Users Folder Location in Windows 10) because that seems to do a really good job explaining this in detail.

    As noted, I don't have any personal experience with this, but I've learned so much from Kari's tutorials that I think I'll go through that tutorial myself in the next day or two just to educate myself of the topic
      My Computers


  9. Posts : 25
    Windows 10 Enterprise LTSC 21H1
       #398

    hsehestedt said:
    @JeepWillys58,

    I must admit that I have no personal experience moving user profiles so I would defer to Kari's comments on the matter.

    I know that you saw Kari's post on the topic here:

    Create media for automated unattended install of Windows 10

    Please make sure to look at the tutorial he links to in that post (Move Users Folder Location in Windows 10) because that seems to do a really good job explaining this in detail.

    As noted, I don't have any personal experience with this, but I've learned so much from Kari's tutorials that I think I'll go through that tutorial myself in the next day or two just to educate myself of the topic
    Hi again dear friend @hsehestedt

    I asked you why I thought you had already done this too and would have some experience to share with me.

    As for the topic of our friend @Kari, it is really excellent and very detailed and I am relying entirely on it, leaving aside what I already did, as if I had no knowledge on the subject or even on installation, to avoid addictions acquired by over the time that we all certainly have, also known as, "my way of doing this", which may be wrong at some point and there is nothing better than doing everything the way someone else does to really learn and improve.

    After I finish everything, I come back to leave my considerations.

    A big hug. Stay well and safe, both you and yours.

    Regards @JeepWillys58

    - - - Updated - - -

    Kari said:
    International-Core? Absolutely not!

    ProgramData folder in Windows 10 cannot be relocated. If you do it, it totally screws your Windows installation.

    To relocate Users folder is easy, I do it every time I redeploy or reinstall Windows 10. Just add the following code to settings pass OobeSystem, under component Microsoft-Windows-Shell-Setup:

    Code:
    <FolderLocations>
    <ProfilesDirectory>X:\Users</ProfilesDirectory>
    </FolderLocations>

    Tutorial: Move Users Folder Location in Windows 10

    Replace drive X: with your preferred drive.

    Notice that the target drive must exist when OOBE starts, so the partition must be created in Part 3 in this tutorial.

    I've relocated the whole Users folder in every Windows installation since early beta days of Vista, never had any issues with it.

    Kari
    Hi again dear friend @Kari

    I have one more question for you regarding the relocation of the user profile folder:

    When I arrived at part 7.11, I was unsure about the command to capture the image, since the users' profile folder is no longer on the "C: " volume, but on the "D: " volume, and on the the command mentioned in the tutorial is referenced only the Volume "C: ".

    Could you tell me if this image capture will be done anyway or if it is necessary to change it?

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    7.11) When booted from install media, press SHIFT + F10 to open Command Prompt. Type diskpart and press Enter (#1 in screenshot below), type list vol and press Enter (#2), type exit and press Enter (#3)

    Check drive letter for Windows partition (#4), all drives are listed under list vol command. In most cases it will be C: but occasionally, depending on hardware and connected disks, booting to WinPE or install media changes drive letters.

    Enter the following command and press Enter to capture Windows image (#5). Replace drive letter C: if necessary in /imagefile, /capturedir and /ScratchDir switches:

    Code:
    dism /capture-image /imagefile:C:\Image\install.wim /capturedir:C:\ /ScratchDir:C:\Scratch /name:"Win10" /description:"My Custom Win10 Image" /compress:maximum /checkintegrity /verify
    Name is required, it must be in quotes and can be anything you'd prefer. Description is optional but recommended, also in quotes.

    Dism will capture the image. Wait until it's done (#6), restart reference machine and let it boot normally from hard disk. Notice that boot will take quite some time because reference machine goes through automated OOBE.

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    Thanks in advanced

    Regards,
    @JeepWillys58

    - - - Updated - - -

    Kari said:
    International-Core? Absolutely not!

    ProgramData folder in Windows 10 cannot be relocated. If you do it, it totally screws your Windows installation.

    To relocate Users folder is easy, I do it every time I redeploy or reinstall Windows 10. Just add the following code to settings pass OobeSystem, under component Microsoft-Windows-Shell-Setup:

    Code:
    <FolderLocations>
    <ProfilesDirectory>X:\Users</ProfilesDirectory>
    </FolderLocations>

    Tutorial: Move Users Folder Location in Windows 10

    Replace drive X: with your preferred drive.

    Notice that the target drive must exist when OOBE starts, so the partition must be created in Part 3 in this tutorial.

    I've relocated the whole Users folder in every Windows installation since early beta days of Vista, never had any issues with it.

    Kari
    Hi again dear friend @Kari

    I have one more question for you regarding the relocation of the user profile folder:

    When I arrived at part 7.11, I was unsure about the command to capture the image, since the users' profile folder is no longer on the "C: " volume, but on the "D: " volume, and on the the command mentioned in the tutorial is referenced only the Volume "C: ".

    Could you tell me if this image capture will be done anyway or if it is necessary to change it?

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    7.11) When booted from install media, press SHIFT + F10 to open Command Prompt. Type diskpart and press Enter (#1 in screenshot below), type list vol and press Enter (#2), type exit and press Enter (#3)

    Check drive letter for Windows partition (#4), all drives are listed under list vol command. In most cases it will be C: but occasionally, depending on hardware and connected disks, booting to WinPE or install media changes drive letters.

    Enter the following command and press Enter to capture Windows image (#5). Replace drive letter C: if necessary in /imagefile, /capturedir and /ScratchDir switches:

    Code:
    dism /capture-image /imagefile:C:\Image\install.wim /capturedir:C:\ /ScratchDir:C:\Scratch /name:"Win10" /description:"My Custom Win10 Image" /compress:maximum /checkintegrity /verify
    Name is required, it must be in quotes and can be anything you'd prefer. Description is optional but recommended, also in quotes.

    Dism will capture the image. Wait until it's done (#6), restart reference machine and let it boot normally from hard disk. Notice that boot will take quite some time because reference machine goes through automated OOBE.

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    Will the capture process work even if the user profiles are on another volume?

    Thanks in advanced

    Regards,
    @JeepWillys58
      My Computer


  10. Posts : 4,187
    Windows 11 Pro, 22H2
       #399

    @Kari, the user @win10freak and I were working together on an issue and they had asked me how they might implement group policy settings in unattended setup.

    I've not done anything with group policy settings in unattended setup but I took a wild guess at what the answer to this might be. Below is my response. If you have any insight into this, could you comment on whether it sounds like I'm on the right track with this?

    -----

    I have to admit that I have not tried to implement group policies in an unattended setup, but I'm going to take a guess at what needs to be done. Again, this is merely a guess, but I can try to research to see if I can determine this for sure.

    My guess is that you would want to follow Kari's tutorial and get to the point where you are in audit mode. At that point you do all the Windows customization and installation of apps.

    My guess is that you would also want to configure your group policy settings at this point. Then, when you proceed and capture your sysprep image, the group policy settings would also be captured.

    Because one of the steps in the creation of your 2 answer files includes the CopyProfile setting, I would assume that the group policy gets copied to each profile created when you create a user.

    I think it highly unlikely that this is something you would do with unattended setup since it is merely designed to automated the initial setup and configuration of Windows. There is way too much in group policy settings to include in answer files.
      My Computers


 

Tutorial Categories

Create media for automated unattended install of Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 16:06.
Find Us




Windows 10 Forums