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

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

  1. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    321
    499
    10
    Of course
    But I must warn you. I'm not a script pro
    Just an "informed" user

    In the examples below the .reg files are in the current directory of the script
    Do not forget to adapt the path according to your use

    example 1
    Code:
    reg import "filename1.reg"
    reg import "filename2.reg"
    reg import "filename3.reg"
    example 2
    Below an improvement of Example 1
    This avoids modifying the script each time you add .reg file
    Basically it scans (command dir) the current folder and each file having for exention .reg the 'reg import' command is executed with the name of the reg file to import
    Code:
    for /f "delims=" %%i in ('dir /b "*.reg"') do (
       reg import "%%i"
    )
    example 3
    convert a .reg file to script
    (method I prefer.Clean. less cleaning to do after installing windows)
    For the conversion I use Reg Converter
    It suits me perfectly. It is freeware and predominatingly portable

    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders]
    "My Video"="D:\\Videos"
    "My Pictures"="D:\\Pictures"
    "Desktop"="D:\\Desktop"
    "{56784854-C6CB-462B-8169-88E350ACB882}"="D:\\Contacts"
    "Favorites"="D:\\Favorites"
    "My Music"="D:\\Music"
    "{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}"="D:\\Searches"
    "{374DE290-123F-4565-9164-39C4925E467B}"="D:\\Downloads"
    "Personal"="D:\\Documents"
    "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}"="D:\\Links"
    "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}"="D:\\Saved Games"
    
    [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]
    "Desktop"=hex(2):44,00,3a,00,5c,00,44,00,65,00,73,00,6b,00,74,00,6f,00,70,00,\
      00,00
    "Favorites"=hex(2):44,00,3a,00,5c,00,46,00,61,00,76,00,6f,00,72,00,69,00,74,00,\
      65,00,73,00,00,00
    "My Music"=hex(2):44,00,3a,00,5c,00,4d,00,75,00,73,00,69,00,63,00,00,00
    "My Pictures"=hex(2):44,00,3a,00,5c,00,50,00,69,00,63,00,74,00,75,00,72,00,65,\
      00,73,00,00,00
    "My Video"=hex(2):44,00,3a,00,5c,00,56,00,69,00,64,00,65,00,6f,00,73,00,00,00
    "Personal"=hex(2):44,00,3a,00,5c,00,44,00,6f,00,63,00,75,00,6d,00,65,00,6e,00,\
      74,00,73,00,00,00
    "{374DE290-123F-4565-9164-39C4925E467B}"=hex(2):44,00,3a,00,5c,00,44,00,6f,00,\
      77,00,6e,00,6c,00,6f,00,61,00,64,00,73,00,00,00
    "{754AC886-DF64-4CBA-86B5-F7FBF4FBCEF5}"=hex(2):44,00,3a,00,5c,00,44,00,65,00,\
      73,00,6b,00,74,00,6f,00,70,00,00,00
    "{56784854-C6CB-462B-8169-88E350ACB882}"=hex(2):44,00,3a,00,5c,00,43,00,6f,00,\
      6e,00,74,00,61,00,63,00,74,00,73,00,00,00
    "{F42EE2D3-909F-4907-8871-4C22FC0BF756}"=hex(2):44,00,3a,00,5c,00,44,00,6f,00,\
      63,00,75,00,6d,00,65,00,6e,00,74,00,73,00,00,00
    "{0DDD015D-B06C-45D5-8C4C-F59713854639}"=hex(2):44,00,3a,00,5c,00,50,00,69,00,\
      63,00,74,00,75,00,72,00,65,00,73,00,00,00
    "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}"=hex(2):44,00,3a,00,5c,00,4c,00,69,00,\
      6e,00,6b,00,73,00,00,00
    "{A0C69A99-21C8-4671-8703-7934162FCF1D}"=hex(2):44,00,3a,00,5c,00,4d,00,75,00,\
      73,00,69,00,63,00,00,00
    "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}"=hex(2):44,00,3a,00,5c,00,53,00,61,00,\
      76,00,65,00,64,00,20,00,47,00,61,00,6d,00,65,00,73,00,00,00
    "{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}"=hex(2):44,00,3a,00,5c,00,53,00,65,00,\
      61,00,72,00,63,00,68,00,65,00,73,00,00,00
    "{7D83EE9B-2244-4E70-B1F5-5393042AF1E4}"=hex(2):44,00,3a,00,5c,00,44,00,6f,00,\
      77,00,6e,00,6c,00,6f,00,61,00,64,00,73,00,00,00
    "{35286A68-3C57-41A1-BBB1-0EAE73D76C95}"=hex(2):44,00,3a,00,5c,00,56,00,69,00,\
      64,00,65,00,6f,00,73,00,00,00
    
    Code:
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Video" /t REG_SZ /d "D:\Videos" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Pictures" /t REG_SZ /d "D:\Pictures" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop" /t REG_SZ /d "D:\Desktop" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{56784854-C6CB-462B-8169-88E350ACB882}" /t REG_SZ /d "D:\Contacts" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Favorites" /t REG_SZ /d "D:\Favorites" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Music" /t REG_SZ /d "D:\Music" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}" /t REG_SZ /d "D:\Searches" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{374DE290-123F-4565-9164-39C4925E467B}" /t REG_SZ /d "D:\Downloads" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal" /t REG_SZ /d "D:\Documents" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}" /t REG_SZ /d "D:\Links" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}" /t REG_SZ /d "D:\Saved Games" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Desktop" /t REG_EXPAND_SZ /d "D:\Desktop" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Favorites" /t REG_EXPAND_SZ /d "D:\Favorites" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Music" /t REG_EXPAND_SZ /d "D:\Music" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Pictures" /t REG_EXPAND_SZ /d "D:\Pictures" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "My Video" /t REG_EXPAND_SZ /d "D:\Videos" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /t REG_EXPAND_SZ /d "D:\Documents" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{374DE290-123F-4565-9164-39C4925E467B}" /t REG_EXPAND_SZ /d "D:\Downloads" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{754AC886-DF64-4CBA-86B5-F7FBF4FBCEF5}" /t REG_EXPAND_SZ /d "D:\Desktop" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{56784854-C6CB-462B-8169-88E350ACB882}" /t REG_EXPAND_SZ /d "D:\Contacts" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{F42EE2D3-909F-4907-8871-4C22FC0BF756}" /t REG_EXPAND_SZ /d "D:\Documents" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{0DDD015D-B06C-45D5-8C4C-F59713854639}" /t REG_EXPAND_SZ /d "D:\Pictures" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}" /t REG_EXPAND_SZ /d "D:\Links" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{A0C69A99-21C8-4671-8703-7934162FCF1D}" /t REG_EXPAND_SZ /d "D:\Music" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}" /t REG_EXPAND_SZ /d "D:\Saved Games" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}" /t REG_EXPAND_SZ /d "D:\Searches" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{7D83EE9B-2244-4E70-B1F5-5393042AF1E4}" /t REG_EXPAND_SZ /d "D:\Downloads" /f
    Reg.exe add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "{35286A68-3C57-41A1-BBB1-0EAE73D76C95}" /t REG_EXPAND_SZ /d "D:\Videos" /f
     
  2. ceo54

    ceo54 MDL Addicted

    Aug 13, 2015
    867
    361
    30
    Thank you migascalp. I think I'll take the third option and convert the .reg files into executable commands to write to registry. I have known about firstlogon.cmd for a long time but I didn't know how to get the setup to initiate the script.

    So firstlogon.cmd for the system configuration and firstlogon.cmd for configuring the Admin account. Now as a last step I need to learn about OOBE.cmd how it works, what are it's limitations and how to use it.

    Thanks again.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    321
    499
    10
    I have been looking for a long time how to use firstlogon.cmd but never found
    So I ended up using the HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce key
    To learn more about OOBE.cmd look Multi-OEM/Retail Project {MRP} - Mk3
     
  4. JeepWillys58

    JeepWillys58 MDL Addicted

    Nov 6, 2010
    581
    365
    30
    I dear friend @s1ave77

    Fisrt of all I hope that you and yours are well and that your immunity is strong to fight Coronavirus and get out of this period unscathed.

    For this your exemple, can you tell me how can I make an installation script that formats the hd in order to have one partition for the system and another for the data and that the users folder is transferred to this second partition?

    Thanks in advanced.
    Regards
    @JeepWillys58
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. sebus

    sebus MDL Guru

    Jul 23, 2008
    6,356
    2,026
    210
  6. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    I have some questions:
    What are the Parameters for silent install of thebat.msi (Mailprog)?

    And in SetupComplete.cmd i have del /q /f "%0" this deletes the SetupComplete right?
    Which code delete the C:\Windows\Setup\Scripts folder when it is all finished and
    this i have to put in the firstlogon.cmd right?
     
  7. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,226
    84,919
    340
    Code:
    cd \
    (goto) 2>nul&rd /s /q "%~dp0"
     
  8. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    Dont work - do i have only to copy & paste your code in the in the last row of the firstlogon.cmd?
     
  9. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    I have this code:

    Code:
    xcopy TheBat!.lnk "%HOMEPATH%\Desktop" /q /r /k /y
    xcopy TheBat!.lnk "%AppData%\Microsoft\Windows\Start Menu\Programs\Startup\" /q /r /k /y
    
    RD /S /Q "%windir%\\setup"
    exit
    Both xcopy codes don't work and delete also^^
     
  10. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    321
    499
    10
    #110 migascalp, May 16, 2020
    Last edited: May 16, 2020
    when possible, you should test parts of script that don't work in a working environment
    example:
    Code:
    xcopy TheBat!.lnk "%HOMEPATH%\Desktop" /q /r /k /y
    xcopy TheBat!.lnk  "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup\" /q /r /k /y
    
    pause
    
    E:\Azerty\Desktop>xcopy TheBat!.lnk "\Users\Azerty\Desktop" /q /r /k /y
    File not found - TheBat!.lnk
    0 fichier(s) copié(s)

    E:\Azerty\Desktop>xcopy TheBat!.lnk "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\" /q /r /k /y
    File not found - TheBat!.lnk
    0 fichier(s) copié(s)

    E:\Azerty\Desktop>pause
    Appuyez sur une touche pour continuer...
    "File not found" -> try with full path for TheBat!.lnk
    %HOMEPATH% don't provide a full path use %HOMEDRIVE%%HOMEPATH%

    For delete Scripts folder try in firstlogon.cmd
    Code:
    REG ADD HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce /v remove_scripts_folder /t REG_SZ /d "cmd.exe /q /c rmdir /s /q %windir%\Setup\Scripts" /f 
    Next Windows startup the folder will be deleted
     
  11. ceo54

    ceo54 MDL Addicted

    Aug 13, 2015
    867
    361
    30
    I use this and it does what it means to do

    Code:
    cd \
    (goto) 2>nul&rd /s /q "%~dp0"
    These of course the last line when the rest of the commands are executed.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    #112 Qu1goN, May 16, 2020
    Last edited: May 16, 2020
    Thank you for the tipp, i try it and install my Win iso in a VM. %HOMEDRIVE%%HOMEPATH% i add to my Firrstlogon.cmd.
    It doesn't work. So i try your Tipp - i make a cmd on desktop in the win in VM with this code:
    Code:
    cd %windir%\Setup\Scripts
    
    xcopy TheBat!Auto.lnk "%AppData%\Microsoft\Windows\Start Menu\Programs\Startup\" /q /r /k /y
    xcopy TheBat!.lnk "%HOMEDRIVE%%HOMEPATH%\Desktop" /q /r /k /y
    xcopy TheBatSicherung.tbk "%HOMEDRIVE%%HOMEPATH%\Desktop" /q /r /k /y
    xcopy Tweaks "%HOMEDRIVE%%HOMEPATH%\Desktop\Tweaks\" /s /q /r /k /y
    
    pause
    The same code which ist used in the Firstlogon.cmd in my win iso when installing windowssetup.
    And now (screenshot) all 4 codes works - why not while installing windows from my iso? There all 4 codes
    doesn't work.

    The other Thing is, i have another code that works like this:
    Code:
    xcopy "%ProgramData%\Microsoft\Windows\Start Menu\Programs\WinRAR\WinRAR.lnk" "%HOMEDRIVE%%HOMEPATH%\Desktop" /q /r /k /y
    xcopy win7roger "%APPDATA%\WinRAR\Themes\win7roger\" /s /q /r /k /y
    xcopy WinRAR.ini "%ProgramFiles%\WinRAR\" /q /r /k /y
    xcopy icons "%WinDir%\icons\" /s /q /r /k /y
    :-(

    About "delete the scripts folder": I try both (in Firstlogon.cmd):
    RD /S /Q "%windir%\\setup"
    and
    cd \
    (goto) 2>nul&rd /s /q "%~dp0"

    I don't know why it doesn't work
    Screen002.jpg

    EDIT/UPDATE:

    Now all works only this doesn't work - i don't know what to do :-( ^^
    Code:
    xcopy TheBat!Auto.lnk" "%AppData%\Microsoft\Windows\Start Menu\Programs\Startup" /q /r /k /y
    EDIT/UPDATE 2:
    All works - oh man... this fu...ing " i forget to delete TheBat!Auto.lnk" <--- ^^
    ...i think so, now i am testing :)
     
  13. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    Ok nothing works, but i found the Problem. It was the thebat.bat i convertet with the Regconverter. The .bat works but
    there stopped the code. Now i deleted the .bat and use my thebat.reg with regedit /s TheBat.reg and all works now :-D
    Also the

    cd \
    (goto) 2>nul&rd /s /q "%~dp0"


    Thank you
     
  14. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    #114 Qu1goN, May 23, 2020
    Last edited: May 23, 2020
    If i have a .lnk file or .ini .... i copy it in my win iso - after windows was installed this files are write protectet.
    WHY? This is not good ^^
     
  15. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    321
    499
    10
    all files in an ISO have attribute RO
    try removing /k in xcopy command line
     
  16. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    #116 Qu1goN, May 23, 2020
    Last edited: May 23, 2020
    How to make a Log-File from the installation of SetupComplete.cmd
    so that i can look what'd wrong / or not :) ...

    Problem is this will not install the gsyncit:
    Code:
    start /wait %WinDir%\Setup\Scripts\Programme\gSyncit64_5_4_79.msi /qn
    Doesn't work.

    EDIT: I found the Problem. For Install, Office NEEDS to be installed ^^
     
  17. ultimate_live

    ultimate_live MDL Expert

    Mar 15, 2011
    1,022
    671
    60
    For a long time I added Microsoft Office 2019 to my W10 Iso. Created sources - $OEM$ Folder. There I put my Office and while installing Windows, Office has also been installed. But now, with the recent Builds of 20H1, 331 and now 388, it doesn´t work anymore. Windows installed, but Office not.
    I used this configuration:

    SetupComplete.cmd

    Code:
    @Echo off
    cd /d "%~dp0"
    
    REM Office
    cd /d "%windir%\Setup\Scripts\Programas"
    setup.exe /configure configuration.xml
    
    rmdir /s /q "%windir%\setup\scripts" >nul 2>&1

    and my configuration.xml

    Code:
    <Configuration>
      <Add OfficeClientEdition="64">
        <Product ID="ProPlus2019Retail">
          <Language ID="pt-br" />
        </Product>
      </Add>
       <Display Level="None" AcceptEULA="TRUE" /> 
    </Configuration>
    
    I don´t know, why it doesn´t install Office anymore. Used older ODT and also the latest version.
     
  18. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    47,287
    94,789
    450
  19. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    I've been doing this for a long time. Updated when a new version comes out. today the installation does not go on - see pictures.
    Then I tried the new versions of YAOCTRU / YAOCTRI (think it was 9.0 and 6.0), but always the same .... :-(
    Screen002.jpg Screen003.jpg

    More i can't see in VMWare Workstation.
     
  20. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    321
    499
    10
    I don't know where your problem comes from
    I can just tell you that it works for me with YAOCTRI v9
    Code:
    Office                    
      Data                    
        16.0.10364.20059      
          i320.cab            
          i640.cab            
          i321036.cab          
          i641036.cab          
          s320.cab            
          s321036.cab          
          stream.x86.fr-FR.dat
          stream.x86.x-none.dat
        v32.cab                
        v32_16.0.10364.20059.cab
    C2R_Config_20200816-1216.ini
    YAOCTRI_Installer.cmd      
    
    Code:
    [configuration]
    SourcePath=""
    Type=Local
    Version=16.0.10364.20059
    Architecture=x86
    O32W64=1
    Language=fr-FR
    LCID=1036
    Channel=Perpetual2019
    CDN=f2e724c1-748f-4b47-8fb8-8e0d210e9208
    Suite=O365ProPlusRetail
    ExcludedApps=Groove,OneDrive,Teams
    UpdatesEnabled=True
    AcceptEULA=True
    PinIconsToTaskbar=False
    ForceAppShutdown=True
    AutoActivate=False
    DisableTelemetry=True
    DisplayLevel=True
    AutoInstallation=True
    
    Maybe see SourcePath in your C2R_Config.ini file