1. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,608
    210
    It's better to use [HEY_ or [-HKEY_ while renaming since many windows reg keys have HKEY_ as subkey names in between.

    Code:
        [hashtable]$equivalents = @{
        "[HKEY_LOCAL_MACHINE\SOFTWARE" = "[HKEY_LOCAL_MACHINE\TK_SOFTWARE";
        "[-HKEY_LOCAL_MACHINE\SOFTWARE" = "[-HKEY_LOCAL_MACHINE\TK_SOFTWARE";
        "[HKEY_CLASSES_ROOT" = "[HKEY_LOCAL_MACHINE\TK_SOFTWARE\Classes";
        "[-HKEY_CLASSES_ROOT" = "[-HKEY_LOCAL_MACHINE\TK_SOFTWARE\Classes";
        "[HKEY_LOCAL_MACHINE\SYSTEM" = "[HKEY_LOCAL_MACHINE\TK_SYSTEM";
        "[-HKEY_LOCAL_MACHINE\SYSTEM" = "[-HKEY_LOCAL_MACHINE\TK_SYSTEM";
        "[HKEY_CURRENT_USER" = "[HKEY_LOCAL_MACHINE\TK_NTUSER";
        "[-HKEY_CURRENT_USER" = "[-HKEY_LOCAL_MACHINE\TK_NTUSER";
        "[HKEY_USERS\.Default" = "[HKEY_LOCAL_MACHINE\TK_DEFAULT"}
        "[-HKEY_USERS\.Default" = "[-HKEY_LOCAL_MACHINE\TK_DEFAULT"} 
    
     
  2. mhussain

    mhussain MDL Senior Member

    Oct 1, 2012
    368
    144
    10
    hi there,
    i'm so sorry if this question has been asked before, but would it be possable to have paralelle processes performed at one time?
    e.g when adding drivers they are added one at a time currently but if it was possible to have more than one driver/removal process performed at the same time, it would speed things up specially on multi core systems like mine is,
    sorry if it's been asked allready,
    maybe a switch could be added?
    thanks for reading my question,
    i'm visually impared and if there are spelling errors i am sorry about them.
     
  3. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,608
    210
    DOS Batch scripting runs step by step and Toolkit just calls the DISM.exe to perform all image related operations except component removal.

    The Toolkit does not have control over how the DISM.exe will process the operation, may be in DISM API there might be option to run parallel tasks.

     
  4. spidernz

    spidernz MDL Senior Member

    May 20, 2011
    390
    114
    10
    parallelism will be out with Windows 20
    Windows is quite inefficient with current hardware so i wouldn't expect thier supporting software like dsim to be efficient.
     
  5. Windows 10 User

    Windows 10 User MDL Guru

    Feb 2, 2017
    2,005
    122
    90
    #11886 Windows 10 User, Aug 27, 2019
    Last edited: Aug 27, 2019
    Will it be compatible with 19H2? Will WU restore removed components after installing updates and regardless of that will we be able to install more recent updates after the previous ones?
     
  6. MIMMO61

    MIMMO61 MDL Senior Member

    Aug 19, 2009
    372
    107
    10
    Since I don't know the procedure well with ToolKit, I insert registry tweak and software using the RunOnce Ex procedure.
    The RunOnceEx procedure installs tweaks and software only when the user is created and not for all users.
    My question is whether I can use a dedicated ToolKit section for this purpose.
    Thank you very much
     
  7. Yanta

    Yanta MDL Senior Member

    May 21, 2017
    477
    274
    10
    One of the reasons I have to run my post install script manually, is that I have to change drive letters before the script is run because there are several drives on each of the systems, And Windows windows never seems to allocate them the same way twice. With PCs sharing data the drive letters need to be consistent across each PC.

    With that in mind, does any one know a way that I can change the drive letters from batch (Not with Diskpart)? Then I can integrate my script into my MSMG image

    EDIT: Optical drives need to be re-assigned to and get-disk in powershell does not report optical drives.
     
  8. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,608
    210
    No not tested with 19H2 yet, Yes WU is working but it restores the removed components, Need to test WU with previous updates been already installed.

    Let me release a version, Will further tweak the component removal to fix any issues occurring.

     
  9. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,608
    210
    Did you tried just the RunOnce procedure or else you can use the INF method to commands before the user creation like the one used in .NET FX 4.7 Pack for Windows 7.

    Will try to add an option in Toolkit to import tweaks from registry file.

     
  10. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,608
    210
    Instead of changing the drive letter, why don't you get the drive letter containing your script and assign it in your script.

    Here's the command to get Optical driver letter in PowerShell

    Code:
    Get-CimInstance Win32_LogicalDisk | ?{ $_.DriveType -eq 5} | select DeviceID
    
    Changing the Optical driver letter in PowerShell

    Code:
    # Set CD/DVD Drive to A:
    $cd = $NULL
    $cd = Get-WMIObject -Class Win32_CDROMDrive -ComputerName $env:COMPUTERNAME -ErrorAction Stop
    if ($cd.Drive -eq "D:")
    {
       Write-Output "Changing CD Drive letter from D: to A:"
       Set-WmiInstance -InputObject ( Get-WmiObject -Class Win32_volume -Filter "DriveLetter = 'd:'" ) -Arguments @{DriveLetter='a:'}
    }
    
    or

    Code:
    # Set CD/DVD Drive to A:
    Get-WmiObject -Class Win32_volume -Filter 'DriveType=5' |
      Select-Object -First 1 |
      Set-WmiInstance -Arguments @{DriveLetter='A:'}
    
     
  11. Windows 10 User

    Windows 10 User MDL Guru

    Feb 2, 2017
    2,005
    122
    90
    Could you check if after removing (or not) the restored components (if you find a way to remove them [or even better, prevent them from being reinstalled after installing an update via WU]) you can install a following CU (a second one, so)?
     
  12. Yanta

    Yanta MDL Senior Member

    May 21, 2017
    477
    274
    10
    Because I always use A: and B: for optical drives. I have 7 disk partitions and mapped network drives that go from M: to Y:, leaving me only 2 drive letters for removable drives. I want to have the same drive letters on each PC for the same purpose. Eg. D:\ is used for Steam, Origin and Battle.net (Always SSD). E:\ is used for downloads, F:\ for DATA, G:\ for my authoring work. H:\ is for MSMG, programming/scripting and related tasks and so on. D: - F: are common to all PCs. All PCs have 1 - 2 Optical drives.

    So I'm looking for a way to change the drive letters within my script so I don't have to install Windows, manually change a few things, then run the script to do all the other tasks (Which includes adding labels to drives, moving the page file, etc.

    My script (which I posted a couple of months ago does get the drive it's running from "SET SRC=%CD:~0,2%", but that is for use within the script. Not the same thing.
     
  13. MIMMO61

    MIMMO61 MDL Senior Member

    Aug 19, 2009
    372
    107
    10
    Thanks for the info.
    You could kindly tell me the link where I can
    understand how the INF method works to control before the creation of the user or the one used in the .NET FX 4.7 Pack for Windows 7.
    Thank you very much
     
  14. budzos

    budzos MDL Expert

    Mar 13, 2009
    1,013
    2,299
    60
    Hello all,
    Trying to convert a Windows 8.1 Core Single Language IR3 x64 iso to Pro with no media center using Toolkit version 8.8 and it always converts to the mediacenter version.
    Am I doing something wrong or is it not possible?
    Thanks, budzos
     
  15. cuzzon

    cuzzon MDL Novice

    Jul 27, 2017
    13
    7
    0
    Just a note : some .reg files found on net that are used for tweaking live systems don't always translate well to offline registry editing in wim image. Mainly because wim reg entries appear to originate from different locations in hives and then get copied/set from there. I've become aware of this when i used WinToolkit on Win7, it made changes that stuck but i manually couldn't get it to work. Now same things repeat. It is a matter of tracking down changes, so i'll try that.
     
  16. cometti

    cometti MDL Novice

    Mar 31, 2015
    12
    2
    0
    @MSMG

    Thx for your excellent work!!
     
  17. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,608
    210
    #11898 MSMG, Aug 29, 2019
    Last edited: Aug 29, 2019
    (OP)
    Adding the reg commands directly to RunOnce should do your tasks

    Code:
    [HKEY_LOCAL_MACHINE\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]
    "Reg1"="REG ADD HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ReserveManager /v ShippedWithReserves /t REG_DWORD /d 0 /f"
    
    Also You can use the SetupComplete.cmd method to run the reg commands too

    And, here's a sample example to use the Inf method to execute the complex commands, in the below case I have used just the reg commands.

    Save the below contents to a file CustromReg.inf under the Mounted Image <Windows\Inf> folder

    Code:
    ;
    ; File Name: CustromReg.inf
    ; Windows Custom Registry Settings
    ;
    ; Version 1.1
    ;
    [Version]
    Signature=$Windows NT$
    
    [DefaultInstall.ntx86]
    RunPostSetupCommands=Register.CustromReg.x86
    Cleanup=1
    
    [DefaultInstall.ntamd64]
    RunPostSetupCommands=Register.CustomReg.x64, Register.CustomReg.x86
    Cleanup=1
    
    ; 32-bit Section
    ; %11% is System32 folder
    [Register.CustomReg.x86]
    
    ; Disable Windows Update Reserve Storage Manager
    %11%\Reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" /v "ShippedWithReserves" /t REG_DWORD /d "0" /f
    
    ; Force .NET Programs to Use Newest .NET Framework
    %11%\Reg.exe add "HKLM\SOFTWARE\Microsoft\.NETFramework" /v "OnlyUseLatestCLR" /t REG_DWORD /d "1" /f
    
    ; Remove Windows Explorer Navigation 3D Objects
    %11%\Reg.exe delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
    
    ; 64-bit Section
    ; %11% is System32 folder
    ; %10% is SysWOW64 folder
    [Register.CustomReg.x64]
    
    ; Remove Windows Explorer Navigation 3D Objects
    %11%\Reg.exe delete "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}"
    
    
    Add the below entries to Image offline registry

    For 32-bit

    Code:
    [HKEY_LOCAL_MACHINE\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]
    "!0CustomReg"="rundll32.exe advpack.dll,LaunchINFSection CustromReg.inf,DefaultInstall.ntx86,1,N"
    
    For 64-bit

    Code:
    [HKEY_LOCAL_MACHINE\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]
    "!0CustomReg"="rundll32.exe advpack.dll,LaunchINFSection CustromReg.inf,DefaultInstall.ntamd64,1,N"
    
     
  18. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,608
    210
    Use v9.3 for doing all tasks other than component removal.

     
  19. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,608
    210
    Yes some keys needs to be properly checked by the user before using it in offline image.

    I tested your PS code it seems not writing the replaced content, did you checked with the code

    Code:
    $input_values = Get-ChildItem -Path "*.reg"
    
    foreach ($file in $input_values)
    {
        [System.Collections.ArrayList]$content = Get-content -Path $file | Where { $_ -notmatch "^(\s+)?;|^\s*$" }
     
        [hashtable]$equivalents = @{
        "[HKEY_LOCAL_MACHINE\SOFTWARE" = "[HKEY_LOCAL_MACHINE\TK_SOFTWARE";
        "[-HKEY_LOCAL_MACHINE\SOFTWARE" = "[-HKEY_LOCAL_MACHINE\TK_SOFTWARE";
        "[HKEY_CLASSES_ROOT" = "[HKEY_LOCAL_MACHINE\TK_SOFTWARE\Classes";
        "[-HKEY_CLASSES_ROOT" = "[-HKEY_LOCAL_MACHINE\TK_SOFTWARE\Classes";
        "[HKEY_LOCAL_MACHINE\SYSTEM" = "[HKEY_LOCAL_MACHINE\TK_SYSTEM";
        "[-HKEY_LOCAL_MACHINE\SYSTEM" = "[-HKEY_LOCAL_MACHINE\TK_SYSTEM";
        "[HKEY_CURRENT_USER" = "[HKEY_LOCAL_MACHINE\TK_NTUSER";
        "[-HKEY_CURRENT_USER" = "[-HKEY_LOCAL_MACHINE\TK_NTUSER";
        "[HKEY_USERS\.Default" = "[HKEY_LOCAL_MACHINE\TK_DEFAULT";
        "[-HKEY_USERS\.Default" = "[-HKEY_LOCAL_MACHINE\TK_DEFAULT"} 
    
        [string]$output = ""
        [string]$newline = ""
        foreach($line in $content)
        {
            if ($line -match "^\[.*\]$")
            {
                foreach($key in $equivalents.Keys)
                {
                    if ($line.Contains($key))
                    {
                        $newline = $line.Replace($key, $equivalents[$key])
                        break
                    }
                }
            }
            else
            {
                $newline = $line
            }
     
            $output += $newline + "`n"
        }
        $filename = [System.IO.Path]::GetFileName($file)
        $path =  [System.IO.Path]::GetDirectoryName($file)
        Set-Content -Path ($path + "\Converted_" + $filename) -Value $output
    }
    
    Used the below command from command line and the CustomRegistry folder contains a set of reg files

    Code:
    PowerShell -ExecutionPolicy Bypass -File .\ConvertRegKeys.ps1 .\CustomRegistry