[REPO/HOW-TO/CHAT] Audit/Sysprep/Generalize; Setupcomplete/Firstlogon; Silent Install

Discussion in 'Scripting' started by s1ave77, Feb 11, 2017.

  1. kal

    kal MDL Member

    Aug 18, 2007
    105
    20
    10
    I'm facing an issue to script the default browser to Chrome. It seems impossible in Windows 10 via a powershell/batch script. Do I have to rely on sysprep for this ? :(
     
  2. kal

    kal MDL Member

    Aug 18, 2007
    105
    20
    10
  3. atplsx

    atplsx MDL Addicted

    May 11, 2009
    521
    1,328
    30
    there are things I want to add,
    if use hyper-v vhd or vhdx virtual disks mount windows 10 easly
    if use virtualbox or vmware use this imdisk toolkit. install the program, select vdi or vmdk right click mount drive
    https://sourceforge.net/projects/imdisk-toolkit/files/
     
  4. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,141
    84,319
    340
    VMware can use vhd too
     
  5. Xariwey

    Xariwey MDL Junior Member

    Mar 26, 2017
    71
    12
    0
    Sorry if i bump this threat, found this on other threat and thought it also needed to be here..

    Updated exclution list from abbodi1406
    https://forums.mydigitallife.net/threads/create-wim-from-installed-system.76839/#post-1426593

    Code:
    [ExclusionList]
    \hiberfil.sys
    \pagefile.sys
    \swapfile.sys
    \System Volume Information
    \$Recycle.Bin\*
    \Recycler
    \Recycled
    \Windows\CSC
    \winpepge.sys
    \$windows.~ls
    \$windows.~bt
    \Boot
    \Recovery
    \Recovery.txt
    \bootsect.bak
    \ProgramData\Microsoft\Diagnosis\ETLLogs\*
    \ProgramData\Microsoft\Network\Downloader\*
    \ProgramData\Microsoft\Windows\SQM
    \Users\Administrator
    \Users\*\NTUSER.DAT*.TM.blf
    \Users\*\NTUSER.DAT*.regtrans-ms
    \Users\*\NTUSER.DAT*.log*
    \Users\*\AppData\Local\Microsoft\Windows\Explorer\*.etl
    \Users\*\AppData\Local\Microsoft\Windows\INetCache\IE\*
    \Users\*\AppData\Local\Microsoft\Windows\WebCache\*
    \Users\*\AppData\Local\Microsoft\Terminal Server Client\Cache\*
    \Windows\AppCompat\Programs\Amcache.hve*.TM.blf
    \Windows\AppCompat\Programs\Amcache.hve*.regtrans-ms
    \Windows\AppCompat\Programs\Amcache.hve*.log*
    \Windows\CSC
    \Windows\Debug\*
    \Windows\inf\*.etl
    \Windows\inf\*.ev*
    \Windows\inf\*.log
    \Windows\Logs\CBS\*
    \Windows\Logs\DISM
    \Windows\Logs\DPX
    \Windows\Logs\dosvc\*
    \Windows\Logs\WindowsUpdate\*
    \Windows\Logs\PBR
    \Windows\Logs\*.log
    \Windows\Microsoft.NET\Framework\v2.0.50727\*.log
    \Windows\Microsoft.NET\Framework\v4.0.30319\*.log
    \Windows\Microsoft.NET\Framework64\v2.0.50727\*.log
    \Windows\Microsoft.NET\Framework64\v4.0.30319\*.log
    \Windows\Panther\*.etl
    \Windows\Panther\*.log
    \Windows\Panther\FastCleanup
    \Windows\Panther\img
    \Windows\Panther\Licenses
    \Windows\Panther\MigLog*.xml
    \Windows\Panther\Resources
    \Windows\Panther\Rollback
    \Windows\Panther\Setup*
    \Windows\Panther\UnattendGC
    \Windows\Panther\upgradematrix
    \Windows\Prefetch\*
    \Windows\security\database\*.chk
    \Windows\security\database\*.log
    \Windows\security\database\*.jrs
    \Windows\ServiceProfiles\LocalService\AppData\Local\FontCache-S-1-5-21-*.dat
    \Windows\ServiceProfiles\LocalService\NTUSER.DAT*.TM.blf
    \Windows\ServiceProfiles\LocalService\NTUSER.DAT*.regtrans-ms
    \Windows\ServiceProfiles\LocalService\NTUSER.DAT*.log*
    \Windows\ServiceProfiles\NetworkService\NTUSER.DAT*.TM.blf
    \Windows\ServiceProfiles\NetworkService\NTUSER.DAT*.regtrans-ms
    \Windows\ServiceProfiles\NetworkService\NTUSER.DAT*.log*
    \Windows\servicing\Packages\wuindex.xml
    \Windows\servicing\Sessions\*_*.xml
    \Windows\servicing\Sessions\Sessions.back.xml
    \Windows\SoftwareDistribution
    \Windows\System32\catroot2\*.txt
    \Windows\System32\catroot2\*.chk
    \Windows\System32\catroot2\*.log
    \Windows\System32\catroot2\*.jrs
    \Windows\System32\config\*.TM.blf
    \Windows\System32\config\*.regtrans-ms
    \Windows\System32\config\*.log*
    \Windows\System32\config\RegBack\*
    \Windows\System32\config\systemprofile\*.TM.blf
    \Windows\System32\config\systemprofile\*.regtrans-ms
    \Windows\System32\config\systemprofile\*.log*
    \Windows\System32\config\TxR\*.blf
    \Windows\System32\config\TxR\*.regtrans-ms
    \Windows\System32\CodeIntegrity\bootcat.cache
    \Windows\System32\LogFiles\AIT\*
    \Windows\System32\LogFiles\SQM\*
    \Windows\System32\LogFiles\WMI\RtBackup\*.etl
    \Windows\System32\SMI\Store\Machine\SCHEMA.DAT*.TM.blf
    \Windows\System32\SMI\Store\Machine\SCHEMA.DAT*.regtrans-ms
    \Windows\System32\SMI\Store\Machine\SCHEMA.DAT*.log*
    \Windows\System32\Sysprep\Panther
    \Windows\System32\Sysprep\Sysprep_succeeded.tag
    \Windows\System32\wdi\LogFiles\*
    \Windows\System32\wfp\*.etl
    \Windows\System32\winevt\Logs\*
    \Windows\System32\winevt\TraceFormat\*
    \Windows\Temp\*
    \Windows\WinSxS\ManifestCache\*
    \Windows\WinSxS\Temp\*
    \Windows\*.log
    
    [CompressionExclusionList]
    *.mp3
    *.zip
    *.cab
    *.wmv
    *.wma
    *.wim
    *.swm
    *.dvr-ms
    \windows\inf\*.pnf
    *.rar
    *.7z
     
  6. joluboga

    joluboga MDL Member

    Dec 4, 2011
    238
    114
    10
    #66 joluboga, May 2, 2018
    Last edited: May 2, 2018
    I followed the Audit/Sysprep/Generalize tutorial to a T, and the final result didn't work for me.

    I used the new 1803 iso, ran the installation of Windows 10 Pro, got into audit mode during the very first config screen, restarted as an Admin, installed Office 365, winrar, foobar, vlc, dobe reader and made a few changes to the general config in control panel, restarted again, ran sysprep as per the instructions.

    The system shutdown without issues. I captured the volume to install.wim, using that exceptions file on DISM.

    I grabbed the resulting install.wim and replaced the original on the iso with the new one. I tried to install the new iso on a VM and right after I skipped the screen where it asks for a serial number, an error message appeared: "Windows no pudo mostrar las imágenes disponibles para la instalación", which loosely translates to "Windows couldn't show the available images for the installation".

    If I run the Get-WIMInfo command on dism, the info appears to be fine:

    C:\WINDOWS\system32>Dism /Get-WIMInfo /WimFile:c:\wim\install.wim
    Deployment Image Servicing and Management tool
    Version: 10.0.17134.1
    Details for image : c:\wim\install.wim
    Index : 1
    Name : Windows 10 Pro
    Description : Windows 10 Pro
    Size : 20,263,369,269 bytes
    The operation completed successfully.


    If I try to open the file with 7zip, an error message appears that says something about being unable to open this file as a compressed file.

    I don't know what else to try. Any clues? :confused:
     
  7. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Please show output for:
    Code:
    Dism /Get-WIMInfo /WimFile:c:\wim\install.wim /Index:1
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. joluboga

    joluboga MDL Member

    Dec 4, 2011
    238
    114
    10
    Hey s1ave77, here you go:

    Deployment Image Servicing and Management tool
    Version: 10.0.17134.1
    Details for image : c:\wim\install.wim
    Index : 1
    Name : Windows 10 Pro
    Description : Windows 10 Pro
    Size : 20,263,369,269 bytes
    WIM Bootable : No
    Architecture : x64
    Hal : acpiapic
    Version : 10.0.17134
    ServicePack Build : 1
    ServicePack Level : 0
    Edition : <undefined>
    Installation : <undefined>
    ProductType : WinNT
    ProductSuite : Terminal Server
    System Root : WINDOWS
    Directories : 25724
    Files : 117055
    Created : 30/04/2018 - 11:06:05 p. m.
    Modified : 01/05/2018 - 05:29:11 a. m.
    Languages :
    es-MX (Default)
    The operation completed successfully.
     
  9. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,104
    24,378
    340
    Had this happen when capturing with dism. Problem is the undefined edition flag. I use imagex or wimlib-imagex to capture ever since.

    To write the missing flag best use imagex:
    Code:
    imagex /flags "Professional" /info "c:\wim\install.wim" 1 "Windows 10 Pro" "Windows 10 Pro" /CHECK
    Then try again.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. joluboga

    joluboga MDL Member

    Dec 4, 2011
    238
    114
    10
    #70 joluboga, May 3, 2018
    Last edited: Aug 10, 2018
    Thank you for your help, S1ave77!! Although I ended up following your other tip of capturing the wim with wimlib-imagex and that one worked like a charm! The edition flag now shows the proper edition and I can even open it with 7zip now.
     
  11. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    47,024
    93,862
    450
    I was playing with windows 8.1 with update:
    Code:
    ---------------------------
    Checksum information
    ---------------------------
    Name: en_windows_8.1_with_update_x64_dvd_6051480.iso
    Size: 4320526336 bytes (4120 MB)
    CRC32: CD5BC9F1
    CRC64: 8F22D60D53642088
    SHA256: D8333CF427EB3318FF6AB755EB1DD9D433F0E2AE43745312C1CD23E83CA1CE51
    SHA1: A8B5DF0B0816280AE18017BC4B119C77B6C6EB79
    BLAKE2sp: 4A5D146510E7FF18C985737702FB046BAA526B07527F4264B0FCD43FC1618A97
    When booting into AUDIT Mode by pressing CTRL+SHIFT+F3 all goes well, but when i shutdown or reboot the VM, the (not by the sysprep tool) the administrator account is disabled:
    [​IMG]
    This was with a clean MSDN install (Core). It also occurs with installs who already have all updates integrated.
     
  12. Nowayy

    Nowayy MDL Novice

    Oct 5, 2016
    8
    0
    0
    Hey!

    I'm currently building my windows 7 with unattended installs so I just want to make sure it's right..

    Summarized:
    1. Created the "Scripts" folder inside the Setup folder on the mounted install.wim (%windir% of course)
    2. Created the sources\$OEM$ folder inside the ISO with these subfolders:

    $$\Setup\Scripts\firstlogon.cmd
    $$\System32\OEM\OEMLOGO.bmp
    $1\Install\vc_2005\vcredist_x64.exe [+ all visual C from 2005-2017]

    3.Started writing the firstlogon.cmd which is currently look like this:

    Code:
    @echo off
    title Installing Visual C Packages and stuff
    ::Code: Nowayy [forums.mydigitallife.net]
    ::Credits go further to: MS i guess.. for making simple things complicated
    setlocal ENABLEDELAYEDEXPANSION
    pushd "%~dp0"
    cd %~dp0
    echo.
    
    echo Visual C++ 2005 ...
    Start /wait %~dp0vc_2005\vcredist_x86.exe /Q
    Start /wait %~dp0vc_2005\vcredist_x64.exe /Q
    cls
    
    echo Visual C++ 2008 ...
    Start /wait %~dp0vc_2008\vcredist_x86.exe /q
    Start /wait %~dp0vc_2008\vcredist_x64.exe /q
    cls
    
    echo Visual C++ 2010 ...
    Start /wait %~dp0vc_2010\vcredist_x86.exe /q /norestart
    Start /wait %~dp0vc_2010\vcredist_x64.exe /q /norestart
    cls
    
    echo Visual C++ 2012 ...
    Start /wait %~dp0vc_2012\vcredist_x86.exe /quiet /norestart
    Start /wait %~dp0vc_2012\vcredist_x64.exe /quiet /norestart
    cls
    
    echo Visual C++ 2013 ...
    Start /wait %~dp0vc_2013\vcredist_x86.exe /quiet /norestart
    Start /wait %~dp0vc_2013\vcredist_x64.exe /quiet /norestart
    cls
    
    echo Visual C++ 2015 ...
    Start /wait %~dp0vc_2015\vcredist_x86.exe /quiet /norestart
    Start /wait %~dp0vc_2015\vcredist_x64.exe /quiet /norestart
    cls
    
    echo Visual C++ 2017 ...
    Start /wait %~dp0vc_2017\vcredist_x86.exe /quiet /norestart
    Start /wait %~dp0vc_2017\vcredist_x64.exe /quiet /norestart
    cls
    
    echo Disabling Telemetry ...
    SCHTASKS /Create /F /RU "SYSTEM" /RL HIGHEST /SC ONSTART /TN BlockW10 /TR "cmd /c %windir%\W10-Block.cmd"
    cls
    I don't really get how this %~dp0 part sets up the current location but still using it so.. ahem.. is this gonna work.?
    I mean the install folders and installers are in the $1\Install while the script is in the $$\Setup\Scripts ...
    Or should I just stick with the %SystemRoot% variable?
     
  13. emikaadeouser

    emikaadeouser MDL Member

    Feb 27, 2018
    119
    97
    10
    I'm trying to create my own setupcomplete.cmd
    I've created ei.cfg like it was sugested here and place it in Sources folder just to make sure it is not ignored during install.
    Code:
    [Channel]
    _Default
    [VL]
    0
    but i still can't prevent Win 10 Pro from installing apps like OneDrive, OneNote, Microsoft Solitaire Collection, BingWeather etc.
    Can anyone take look at it and show me what i'm doing wrong?
    Code:
    @echo off
    reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v OemPreInstalledAppsEnabled /t REG_DWORD /d 0 /f
    reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v PreInstalledAppsEnabled /t REG_DWORD /d 0 /f
    reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SilentInstalledAppsEnabled /t REG_DWORD /d 0 /f
    reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SoftLandingEnabled /t REG_DWORD /d 0 /f
    reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v ContentDeliveryAllowed /t REG_DWORD /d 0 /f
    reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SubscribedContentEnabled /t REG_DWORD /d 0 /f
    reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v PreInstalledAppsEverEnabled /t REG_DWORD /d 0 /f
    reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager /v SystemPaneSuggestionsEnabled /t REG_DWORD /d 0 /f
    reg add HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0 /f
    reg add HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6} /v System.IsPinnedToNameSpaceTree /t REG_DWORD 0 /f
    reg add HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\CloudContent /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f
    
    reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\Subscriptions /f
    reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SuggestedApps /f
    reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v OneDriveSetup /f
    DEL /F /Q "%0%" >nul
     
  14. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,141
    84,319
    340
    OneNote, Solitaire and BingWeather are already installed apps
    you need to modify install.wim and remove them with DISM

    most ContentDeliveryManager values are ignored for Pro/Home
    you need to use LayoutModification.xml to stop other "pending" apps from installing after
     
  15. emikaadeouser

    emikaadeouser MDL Member

    Feb 27, 2018
    119
    97
    10
    Thank you for clarification.
     
  16. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    300
    469
    10
    Hello,
    I would like to use the script below via runonce
    But in the state it break the end of oobe
    Code:
    Reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3" /v "Settings" /t REG_BINARY /d "30000000feffffff02000000010000003e00000028000000000000000000000000040000280000006000000001000000" /f
    taskkill /f /im explorer.exe
    timeout 1
    start explorer.exe
    I found a workaround
    Code:
    :WAIT
    timeout 1
    tasklist /FI "IMAGENAME eq SecurityHealthSystray.exe" 2>NUL | find /I /N "SecurityHealthSystray.exe">NUL
    if %ERRORLEVEL% NEQ 0 goto WAIT
    Reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3" /v "Settings" /t REG_BINARY /d "30000000feffffff02000000010000003e00000028000000000000000000000000040000280000006000000001000000" /f
    taskkill /f /im explorer.exe
    timeout 1
    start explorer.exe
    
    But this solution is not really clean
    Finally, my question:
    How to wait for the end oobe?
    more specifically, how do I know when windows becomes fully functional after startup?


    Source for this tweak
     
  17. slayer9450

    slayer9450 MDL Member

    Aug 3, 2015
    211
    87
    10
    Per post #2 setupcomplete.cmd and oobe.cmd aren't co-existing for me in my Windows 10 install. I have my activation solution in setupcomplete and other stuff I want do in oobe.cmd because for some reason if I try and add anything else to setupcomplete.cmd it just hangs at "Just a moment...". When I go through the OOBE and get to the desktop it's not activated. If oobe.cmd is present does the system ignore setupcomplete.cmd?
     
  18. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    47,024
    93,862
    450
    They can coexist, iirc, oobe.cmd is handled first and setupcomplete.cmd next, but if the oobe.cmd has a bad command or deletion command, it can cause setupcomplete.cmd to not be ran.
     
  19. slayer9450

    slayer9450 MDL Member

    Aug 3, 2015
    211
    87
    10
    For right now until I get both oobe.cmd and setupcomplete.cmd to be work I only have one line of execution in my oobe.cmd. I don't why it would have a problem with that.

    Code:
    @echo off
    setlocal ENABLEDELAYEDEXPANSION
    pushd "%~dp0"
    cd %~dp0
    start /wait Ninite\Ninite.exe
    exit
     
  20. Flipp3r

    Flipp3r MDL Expert

    Feb 11, 2009
    1,962
    904
    60
    https://docs.microsoft.com/en-us/wi.../desktop/add-a-custom-script-to-windows-setup
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...