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

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

  1. slayer9450

    slayer9450 MDL Member

    Aug 3, 2015
    211
    87
    10
    I'm not using OEM product keys. If oobe.cmd exists does the install just assume OEM product keys are being used and disables setupcomplete.cmd?
     
  2. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    320
    499
    10
    I do not know if it will help you but here is an example of my use
    Code:
    $$                         
      Setup                   
        Files                 
          7-Zip.exe           
          Firefox.exe         
          HashCheck.exe       
          MPC-HC.exe           
          Notepad++.exe       
        Scripts               
          Win32               
            key.cmd           
            SppExtComObjHook.dll
            SvcTrigger.xml     
          x64                 
            SppExtComObjHook.dll
          DeCompile.exe       
          MRPConfig.ini       
          OEM's.7z             
          OOBE.cmd             
          setupcomplete.cmd   
          WinTel.cmd           
    
    for some tweak and theme: Multi-OEM/Retail Project {MRP} - Mk3
    for activation: KMS_VL_ALL - Smart Activation Script (also works with s1ave77 method)
    for silent install I use SFXMaker by Iuli and/or Bat To Exe Converter by Fatih Kodak

    To know that some tweak and app needs to be installed when the user is logged in
    In this case I use the runonce registry key
    ex:
    Code:
    REG ADD HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce /v Tweak_Reg /t REG_SZ /d "cmd.exe /c start /min %cd%\InstallInRunOnce.cmd ^& exit"
    Finally, to start all installations I paste the command below at the top of the setupcomplet script
    Code:
    for /f "delims=" %%i in ('dir /b %WINDIR%\Setup\Files\*.exe') do (
    "%WINDIR%\Setup\Files\%%i"
    )
    
    sorry for my google translation english
     
  3. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    Hello, my english is not the best :) - So i am a beginner with this things. Meanwhile I have managed to create my own Win10Pro iso with Office2019 and all updates included.
    Now i tryed to include for example WinRAR. I place it the WinRar_v5.90d_64bit.exe in $OEM$\$$\Setup\Scripts an i have this code in my SetupComplete.cmd:
    Code:
    @echo off
    
    call "%WinDir%\Setup\Scripts\YAOCTRIR_Installer.cmd"
    start /wait %WinDir%\Setup\Scripts\WinRar_v5.90d_64bit.exe /s
    del /q /f "%0"
    It works. Now my questions (Is it possible to do this after the installation of WinRAR?):

    Make a Desktopicon of WinRAR
    Copy my WinRAR-Theme "win7roger.theme.rar" to the folder "%APPDATA%\Roaming\WinRAR\Themes"
    Copy my WinRAR-INI "WinRAR.ini" to "Program Files\WinRAR"

    When yes, can sombody write the code pls?
     
  4. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    320
    499
    10
    Hi
    Try this
    all files must be in $OEM$\$$\Setup\Scripts
    add this line in setupcomplete.cmd
    Code:
    reg add HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v firstlogon /t REG_SZ /d %windir%\Setup\Scripts\firstlogon.cmd /f
    
    Create script firstlogon.cmd and add in this
    Code:
    cd %windir%\Setup\Scripts
    xcopy "%ProgramData%\Microsoft\Windows\Start Menu\Programs\WinRAR\WinRAR.lnk" "%HOMEPATH%\Desktop" /q /r /k /y
    xcopy win7roger.theme.rar "%APPDATA%\WinRAR\Themes\" /q /r /k /y
    xcopy WinRAR.ini "%ProgramFiles%\WinRAR" /q /r /k /y
    
     
  5. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    @migascalp Thank you :) the code is working.

    I tested it in a VM and noticed that two things are wrong (my mistake *gg*). I need to extract the win7roger.theme.rar and then i have to copy the extrated folder "win7roger" to the %APPDATA%\WinRAR\Themes\.
    But i have to make the empty folder win7roger and to this i copy the win7roger folder with the files, that will make right folder like WinRAR\Themes\win7roger - if i use only the win7roger folder with the files in,
    it will not make the win7roger folder in WinRAR\Themes and copy the files included in the win7roger folder directly to WinRAR\Themes - hope you know what i mean ^^

    Then i add Firefox and it works. The last program i want to add ist notepad++ but here is a Problem...
    ...during installation there is one restart, then comes up the windows logo, after a while the second restart,
    then the Installation hangs at "one moment please" ---> look at the screenshot attached.

    Here is how my code looks like at the moment (SetupComplete.cmd):
    Code:
    @echo off
    
    call "%WinDir%\Setup\Scripts\YAOCTRIR_Installer.cmd"
    start /wait %WinDir%\Setup\Scripts\WinRar_v5.90d_64bit.exe /s
    start /wait %WinDir%\Setup\Scripts\Firefox_Setup_75.0.exe /s
    start /wait %WinDir%\Setup\Scripts\npp.7.8.5.Installer.x64.exe /s
    reg add HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v firstlogon /t REG_SZ /d %windir%\Setup\Scripts\firstlogon.cmd /f
    del /q /f "%0"
    And the (firstlogon.cmd):
    Code:
    cd %windir%\Setup\Scripts
    xcopy "%ProgramData%\Microsoft\Windows\Start Menu\Programs\WinRAR\WinRAR.lnk" "%HOMEPATH%\Desktop" /q /r /k /y
    xcopy win7roger "%APPDATA%\WinRAR\Themes\" /s /q /r /k /y
    xcopy WinRAR.ini "%ProgramFiles%\WinRAR\" /q /r /k /y
    xcopy Notepad++ "%APPDATA%\" /s /q /r /k /y
    Did you see something wrong?

    [​IMG]
     
  6. sebus

    sebus MDL Guru

    Jul 23, 2008
    6,356
    2,026
    210
    You most likely can not copy anything to
    "%ProgramFiles%\WinRAR\
    as there are no permissions to do so
    or
    "%APPDATA%\"
    does not exist

    Hence it will stay there

    Try to do Ctrl+F10 or Alt+Tab & in Taskmgr see what "hangs" & most likely terminate cmd that runs firstlogon.cmd
     
  7. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    Thx...problem was the Notepad++ - i removed this - don't need it...

    Another thing. The folder "win7roger" (see on the left in attached Screenshot) have to be copied with this code:
    "xcopy win7roger "%APPDATA%\WinRAR\Themes\" /s /q /r /k /y
    But it copy only the files from the folder "win7roger" (see in the middle in attached Screenshot).
    (How it should be (on the right in attached Screenshot))

    I add "win7roger\": "xcopy win7roger "%APPDATA%\WinRAR\Themes\win7roger\" /s /q /r /k /y
    - i don't know if its right or clean code but it works.

    [​IMG]
     
  8. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    320
    499
    10
    try to use winrar from command line or convert rar to rar sfx
    look at the winrar manual
    look post of @s1ave77 it gives a lot of information on how to
    see also MS-DOS help and commands
     
  9. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    Its all good with WinRAR it works now after the installation and thx for the link to MS-Dos help and commands - my english is not the best but i try it, maybe i'll find something in german. :)
     
  10. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    320
    499
    10
    Good luck for the future ;)
     
  11. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    The Future is now ;-)

    Ok step by step ^^ I integratet more Programs, so far so good.

    I can't get one thing done: Copy a Folder named "Icons" to the %WinDir% (C:\Windows). My Code:
    Code:
    xcopy Icons "%WinDir%\Icons\Icons\" /s /q /r /k /y
    What's wrong? ^^

    ((\Icons\Icons\) because the same as WinRAR)
     
  12. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    320
    499
    10
    not read xcopy manual?
    try
    Code:
    xcopy Icons "%windir%\Icons\" /e /y
     
  13. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    I look at it, but my english ^^ and i don't understand this so much. :(

    Thanks, i tried your code but it doesn't work. Alternatively i copy "Icons" to another path (not to WinDir).
     
  14. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    320
    499
    10
    My bad.Sorry :oops:
    The solution was in OP
    Just put the files and/or folders to copy in C:\Windows in the $$ folder
    I just tried it still works

    In my defense I have not used this method since Windows XP
     
  15. Qu1goN

    Qu1goN MDL Junior Member

    Apr 1, 2020
    73
    8
    0
    No it is my... i'm realy sorry. I forgot to copy the icons folder into sources. So there was nothing to copy. :oops:
    Now it works :rolleyes: with
    Code:
    xcopy icons "%WinDir%\icons\" /s /q /r /k /y
     
  16. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    320
    499
    10
    indeed! it doesn't help :)
     
  17. ceo54

    ceo54 MDL Addicted

    Aug 13, 2015
    867
    361
    30
    #97 ceo54, Apr 22, 2020
    Last edited: Apr 22, 2020
    Thank you. Now I understand how can I create and configure the firstlogon.cmd and run it once the user profile is created.

    Will it be possible to integrate the HKCU registry entries through firslogon.cmd ??

    Actually, it will be folder with registry entries, placed in the same Scripts folder as firstlogon.cmd
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. ceo54

    ceo54 MDL Addicted

    Aug 13, 2015
    867
    361
    30
    Strange, I can shutdown or restart, doesn't happen to me However signing out and signing back in does that.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. migascalp

    migascalp MDL Senior Member

    Sep 18, 2009
    320
    499
    10
    Yes
    reg import or reg add HKCU work
     
  20. ceo54

    ceo54 MDL Addicted

    Aug 13, 2015
    867
    361
    30
    Can you give me an example, how to import entire folder full of HKCU .reg files, if possible ?

    Or maybe how can I add them through command prompt.

    Your help is highly appreciated :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...