1. MIMMO61

    MIMMO61 MDL Senior Member

    Aug 19, 2009
    379
    108
    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
     
  2. budzos

    budzos MDL Expert

    Mar 13, 2009
    1,013
    2,300
    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
     
  3. 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.
     
  4. cometti

    cometti MDL Novice

    Mar 31, 2015
    12
    2
    0
    @MSMG

    Thx for your excellent work!!
     
  5. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,627
    210
    #11885 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"
    
     
  6. MSMG

    MSMG MDL Developer

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

     
  7. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,627
    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
    
     
  8. MIMMO61

    MIMMO61 MDL Senior Member

    Aug 19, 2009
    379
    108
    10
  9. budzos

    budzos MDL Expert

    Mar 13, 2009
    1,013
    2,300
    60
    I also removed a bunch of stuff. Should I first remove what I need removed in version 8.8, Then reopen in 9.3 and convert it?
    Thanks for the kind reply MSMG. I have been using Windows 7 forever but need 8.1 for nvme support.
    budzos
     
  10. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,627
    210
    First you use v9.3 to convert the edition and then re-open the image with v8.3 for removal.

    Will add a temporarily solution for component removal for W7/W81 in v9.4 using Remove Windows Component using Package List to avoid using two version of ToolKit.


     
  11. budzos

    budzos MDL Expert

    Mar 13, 2009
    1,013
    2,300
    60
    Thanks again MSMG, I will give that a shot.
    budzos
     
  12. cuzzon

    cuzzon MDL Novice

    Jul 27, 2017
    13
    7
    0
    Bahh i knew it i messed up ! I was running from IDE with working directory holding ps1 and reg files, not from command prompt (with usually workdir set to current user). It was working directory that may have messed things up.
    One other thing i didn't check for is result of $path = [System.IO.Path]::GetDirectoryName($file) it had a backslash. If file resides in root dir, it will have a backslash, but if that is some subdirectory it will not.
    This is relevant as the final filename is built with "\converted_" string inserted.
     
  13. cuzzon

    cuzzon MDL Novice

    Jul 27, 2017
    13
    7
    0
    @MSMG i copied the PS code and modified it to ensure input arguments are properly defined at command line
    Code:
    # test if first argument is defined / given at command line
    if ($args[0] -eq $null)
        {
            # can be replaced with Exit 1 to denote failure if used in batch cmd
            throw [System.IO.DirectoryNotFoundException]::new("Source directory not defined !")
        }
    
    # test if first argument is a directory and exists
    if ((Test-Path -Path $args[0].ToString() -PathType Container) -eq $false)
        {
        throw [System.IO.DirectoryNotFoundException]::new("First argument is not a directory !")
        }
    
    # test if second argument is defined / given at command line
    if ($args[1] -eq $null)
        {
            throw [System.IO.DirectoryNotFoundException]::new("Target directory not defined !")
        }
    
    # test if second argument is a directory and exists
    if ((Test-Path -Path $args[1].ToString() -PathType Container) -eq $false)
        {
            throw [System.IO.DirectoryNotFoundException]::new("Second argument is not a directory !")
        }
    
    # using ToString() for arguments ensures that if supplied directory name is all numbers it won't fail (it won't think its a number but a string)
    # Combine() ensures that if directory path does not have backslash \ at end it will work anyway
    $sourcedir = [System.IO.Path]::Combine($args[0].ToString(),".\") + "\*"
    $targetdir = [System.IO.Path]::Combine($args[1].ToString(),".\")
    
    $input_values = Get-ChildItem -Path $sourcedir -Include *.reg
    
     #moved out of loop, no need to re-define it on each iteration :)
     [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"}
    
    foreach ($file in $input_values)
    {
        #regex ensures that all commented lines are ignored
        [System.Collections.ArrayList]$content = Get-content -Path $file | Where { $_ -notmatch "^(\s+)?;|^\s*$" }
        [string]$output = ""
        [string]$newline = ""
    
        foreach($line in $content)
        {
            # regex ensures to catch all lines with angle brackets (they contain registry keys)
            if ($line -match "^\[.*\]$")
            {
                #search and replace keys to toolkit-compatible format
                foreach($key in $equivalents.Keys)
                {
                    if ($line.Contains($key))
                    {
                        $newline = $line.Replace($key, $equivalents[$key])
                        break
                    }
                }
            }
            else
            {
                $newline = $line
            }
            $output += $newline + "`r`n"
        }
        # $file is of type System.IO.FileSystemInfo so it is simple as referencing its 'Name' property to get actual file name
        Set-Content -Path ($targetdir + $file.Name) -Value $output
    }
    
    
    Note the comments as they provide info on what is added and why.
     
  14. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,627
    210
    Thanks, updated the convert registry script with the new changes.

     
  15. MSMG

    MSMG MDL Developer

    Jul 15, 2011
    6,414
    15,627
    210
    Yes Finished uploading the packs, cleaning up the Toolkit script, updating the change-log and HASH.

    Still pending is to add protection to the ToolKitHelper.exe and re-test it, then pack up, upload and publish the ToolKit.

    Monday, 2 September is the release date.

     
  16. windows builder

    windows builder MDL Guru

    Sep 13, 2017
    2,219
    1,555
    90
    OMG!!! :worthy::worthy::worthy: finally.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. °ツ

    °ツ MDL Addicted

    Jun 8, 2014
    921
    1,208
    30
    I haven't been reading this thread for a long time since I use other software for this task but what happened with the GUI version? It was supposed to be released long time ago.