Windows Tweaking Scripts

Discussion in 'Scripting' started by mdl052020, Jul 29, 2020.

?

Do you like these batch scripts?

This poll will close on Jul 29, 2021 at 10:50.
  1. Yes

    147 vote(s)
    80.3%
  2. No

    9 vote(s)
    4.9%
  3. Will Decide After I Try Any of Script

    29 vote(s)
    15.8%
Multiple votes are allowed.
  1. drew84

    drew84 MDL Addicted

    Mar 13, 2014
    956
    1,490
    30
    I especially like the Naming (description) of The Tweaks - makes it a lot easier to edit configuration according to own needs, as @mdl052020 said - nice contribution
     
  2. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    #362 mdl052020, May 21, 2021
    Last edited: May 21, 2021
    (OP)
    Latest Tweaker Log of 1904x.985 ISO Image With Some New Changes :

    Code:
    *****************************************************************
    ------------------- Ensure Admin Privileges ---------------------
    *****************************************************************
    *****************************************************************
    
    *****************************************************************
    *                Win10 ISO Tweaker Script :: Final Version ::   *
    *                   (c) 2021 by Mydigitallife Member            *
    *****************************************************************
     Tweaker Script :: Final Version :: Started at 21-May-21  9:05:00
    *****************************************************************
    
    *****************************************************************
    --- Extract ISO to Script Path and Create Mount Directory
    *****************************************************************
    
    7-Zip 21.01 alpha (x64) : Copyright (c) 1999-2021 Igor Pavlov : 2021-03-09                                                                                                                                                                                                                                                             Scanning the drive for archives:                                                                                                                                                 1 file, 5063024640 bytes (4829 MiB)                                                                                                                                                                                                                                                                                                                               Extracting archive: ISO\Win10.iso
    --
    Path = ISO\Win10.iso
    Type = Udf
    Physical Size = 5063024640
    Comment = 1904x.985 21-05-20
    Cluster Size = 2048
    Created = 2021-05-20 05:30:00
    
    Everything is Ok
    
    Folders: 85
    Files: 903
    Size:       5071730058
    Compressed: 5063024640
    *****************************************************************
    
    *****************************************************************
    --- Export Windows 10 Single Index of Your Choice to Script Path
    *****************************************************************
    
    [ Before Using Tweaker I Used W10UI by Abbodi1406 to Update WinRE to Latest 1904x.985 as Official M$ ISO's dont have Updated WinRe Wim Image With LCU ]
    
     Wim Image contain following 1 indexes :
    
      [1] Windows 10 Education
    
    Select Single Image Index Number You Want to Export and Tweak :1
    
    Deployment Image Servicing and Management tool
    Version: 10.0.19041.844
    
    Exporting image
    [==========================100.0%==========================]
    The operation completed successfully.
    *****************************************************************
    
    *****************************************************************
    --- Move Back Exported WIM Image to its Source Path
    *****************************************************************
            1 file(s) moved.
    *****************************************************************
    
    *****************************************************************
    --- Mounting Selected Windows 10 WIM image to Mount Directory
    *****************************************************************
    Path          : Mount
    Online        : False
    RestartNeeded : False
    
    *****************************************************************
    
    *****************************************************************
    --- Select and Remove Windows Apps
    *****************************************************************
    
     [ Removed All Other Instances of Provisioned App Packages Plus Optional Features Plus Capabilities Removal to Reduce Size of This Log File ]
    
    VERBOSE: Target Image Version 10.0.19041.985
    
    Path          : Mount
    Online        : False
    RestartNeeded : False
    
    *****************************************************************
    
    *****************************************************************
    --- Select and Remove UnNeeded Windows Packages
    *****************************************************************
    
    [ Here We Removed Text To Speech Package only as it is not removed via Capability Removal ]
    
    VERBOSE: Target Image Version 10.0.19041.985                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    Path          : Mount                                                                                                                                                       
    Online        : False                                                                                                                                                       
    RestartNeeded : False
    
    *****************************************************************
    
    *****************************************************************
    --- Disable Windows Defender Tamper Protection From Offline Image
    *****************************************************************
    
    [ Here We Disable Tamper Protection Plus Cloud Protection ie Dword Value "4" From Offline Image to Remove WD Permenently from OS via Our $OEM$ Package in Latest 1904x.985 ISO]
    [ Let M$ Find Other Way to Most Secure WD Removal and Newly Updated MS Security filter Service Also be disabled via our $OEM$ Package Too in this 1904x.985 ISO's ]
    
    The operation completed successfully.
    Processing ACL of: <machine\OfflineSOFTWARE\Microsoft\Windows Defender\Features>
    
    SetACL finished successfully.
    Processing ACL of: <machine\OfflineSOFTWARE\Microsoft\Windows Defender\Features>
    
    SetACL finished successfully.
    VERBOSE: Performing the operation "New Property" on target "Item: HKEY_LOCAL_MACHINE\OfflineSOFTWARE\Microsoft\Windows Defender\Features Property: TamperProtection".
    
    TamperProtection : 4
    PSPath           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\OfflineSOFTWARE\Microsoft\Windows Defender\Features
    PSParentPath     : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\OfflineSOFTWARE\Microsoft\Windows Defender
    PSChildName      : Features
    PSProvider       : Microsoft.PowerShell.Core\Registry
    
    VERBOSE: Performing the operation "New Property" on target "Item: HKEY_LOCAL_MACHINE\OfflineSOFTWARE\Microsoft\Windows Defender\Features Property: TamperProtectionSource".
    
    TamperProtectionSource : 2
    PSPath                 : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\OfflineSOFTWARE\Microsoft\Windows Defender\Features
    PSParentPath           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\OfflineSOFTWARE\Microsoft\Windows Defender
    PSChildName            : Features
    PSProvider             : Microsoft.PowerShell.Core\Registry
    
    The operation completed successfully.
    *****************************************************************
    
    *****************************************************************
    --- Saving and Unmounting Final Debloated Image
    *****************************************************************
    LogPath : Z:\dism.log
    *****************************************************************
    
    *****************************************************************
    --- Export Install Wim to Compress Maximum
    *****************************************************************
    --- Exporting install.wim to Reduce its Size
    
    Deployment Image Servicing and Management tool
    Version: 10.0.19041.844
    
    Exporting image
    [==========================100.0%==========================]
    The operation completed successfully.
    
    --- Moving Back install.wim to its Source Path
            1 file(s) moved.
    *****************************************************************
    
    *****************************************************************
    --- Reduce ISO Layout to Maximum Extent
    *****************************************************************
    --- Reduced ISO Layout to Maximum Extent
    *****************************************************************
    
    *****************************************************************
    --- Add ei.cfg , pid.txt , autounattend.xml , $OEM$ if Exist Next to Script
    *****************************************************************
    --- Add AutoUnattend.xml to Root of ISO If Present
            1 file(s) copied.
    
    --- Add EI.CFG to ISO Sources If Present
            1 file(s) copied.
    
    --- Add PID.TXT to ISO Sources If Present
    
    --- Add $OEM$ Pack to ISO Sources If Present
    
    409 File(s) copied [ Here I Used My Personal $OEM$ Package with Setup Installers & Drivers via Silent Install Switches ]
    *****************************************************************
    
    *****************************************************************
    --- Create Final Win10 Tweaked ISO
    *****************************************************************
    
    Enter ISO Filename :Win10
    
    OSCDIMG 2.56 CD-ROM and DVD-ROM Premastering Utility
    Copyright (C) Microsoft, 1993-2012. All rights reserved.
    Licensed only for producing Microsoft authorized content.
    
    Scanning source tree
    Scanning source tree complete (225 files in 62 directories)
    
    Computing directory information complete
    
    Image file is 5457444864 bytes (before optimization)
    
    Writing 225 files in 62 directories to Z:\Win10-AIO-Tweaker\Win10.iso
    
    100% complete
    
    Storage optimization saved 28 files, 2048 bytes (1% of image)
    
    After optimization, image file is 5444050944 bytes
    Space saved because of embedding, sparseness or optimization = 14020608
    
    Done.
    *****************************************************************
    
    *****************************************************************
    --- Remove All Extra Files of Project :: Final Version ::
    *****************************************************************
    LogPath : Z:\dism.log
    *****************************************************************
    Tweaker Script :: Final Version :: Completed at 21-May-21  9:15:30
    *****************************************************************
    **************************** The End ****************************
    
    Uploading latest Win10 AIO Tweaker & $OEM$ Pack Second Edition Mid May 2021.

    Log Already Shadowed Whats Changed in Tweaker Script Tool .
    Plus Users Can use Aio Tweaker Tool with MSMG toolkit from Now Onwards as directory hierachy is same . Just extract Tweaker Tool into MSMG Directory & there You are with AIO MSMG + Tweaker + W10UI in one place.

    Lets Talk About $OEM$ Pack Second Edition MID May 2021 here i have used Another example for those people who say that setupcomplete cmd file doesnt work i know cuz they havent used kms key for installation cuz any OEM key used with win10 ISO wont let setupcomplete script to run [ Cross Check %SystemRoot%\Panther\UnattendGC\*.log ]

    Now Everything will be on Your Desktop After installation & wont execute itself after install . User have to execute $RunME cmd file with Elevated Privillages for complete $OEM$ Pack to complete its tweaks & in last your system will reboot after a interval of 60 seconds.

    Thanks & Regards :)
     
  3. Pisdu

    Pisdu MDL Novice

    Aug 5, 2015
    2
    2
    0
    Hi , sorry for "stupid question" how to run this ?
    Ive created a cmd file with that code , putted PowerRun and SetACL in the same folder than run the script as administrator but nothing happens
    What's wrong with that ?
    Thanks a lot !

     
  4. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    Have you Downloaded Both PowerRun & SetAcl Executables then put both next to bat script.

    Edit : I dont have that much time to Wait . Please Reply Fast for on the Go Solution or else i have to log out.

    Thanks & Regards
     
  5. Pisdu

    Pisdu MDL Novice

    Aug 5, 2015
    2
    2
    0
    Yes bat file SetACL PowerRun are on the same folder
     
  6. zbigniew59

    zbigniew59 MDL Member

    May 14, 2016
    130
    39
    10
    There must be two .exe files from these downloaded folders + .bat file
     
  7. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    You must have scripts execution blocked via policy on your host. just unblock scripts execution then try.
     
  8. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    #368 mdl052020, May 24, 2021
    Last edited: May 30, 2021
    (OP)
    $OEM$ June 2021 Pack will be a Wow for Everybody With Almost All Surprises at Every New Fonction via Bat Script.

    Almost All Modern Apps + SystemApps Will be Removed & Some Third Party Good Apps will be installed.

    Sqlite3 is the best way to set isinbox to 0 for machine.srd database at %Programdata%\Microsoft\Windows\AppRepository\*.srd
    Then Execute the Powwershell Commands to Remove Appxpackages for All Users.
    [ Idea Via Win10Retweaker Script Tool by Noel.C ]
    Now i can Say Win10 Converted Perfectly to Win7 Best Experience with a Single Bat Script. Its More then Awesome.

    Edit :
    Script will show a MsgBox to user to not remove three systemapps Highly Recommended [Mandatory Steps to be Followed]
     
  9. drew84

    drew84 MDL Addicted

    Mar 13, 2014
    956
    1,490
    30
    Looking forward to testing
     
  10. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    #370 mdl052020, May 26, 2021
    Last edited: May 30, 2021
    (OP)
    AutoSettingsPS 0.4 Released by Westlife on ru-board . havent found even a single new tweak to to applied in our $OEM$ Pack in this new release . seems like we have already applied all updated tweaks in this new release.

    Secondly Tested latest 1904x.1023 Preview Update with our Latest $OEM$ Pack & found so many reg plus gp tweaks reverted back plus some new tweaks to be applied too.
    hence applied all those & pack is ready with latest Preview Release . Wait for the pack to be released till 1st June 2021 as June 2021 Updated $OEM$ Pack.
     
  11. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    #371 mdl052020, May 29, 2021
    Last edited: May 31, 2021
    (OP)
    Updated Every Script either Offline or Online on First Page of this Thread,
     
  12. ahczwudichao

    ahczwudichao MDL Junior Member

    May 1, 2013
    81
    74
    0
    in addition to my contribution at Win10 Tweaking Scripts

    below 2 addtional PS1 file can be used somewhere for your project, hopefully :p @mdl052020

    function Get-FTA {
    [CmdletBinding()]
    param (
    [Parameter(Mandatory = $false)]
    [String]
    $Extension
    )
    if ($Extension) {
    Write-Verbose "Get File Type Association for $Extension"
    $assocFile = (Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice"-ErrorAction SilentlyContinue).ProgId
    Write-Output $assocFile
    }
    else {
    Write-Verbose "Get File Type Association List"
    $assocList = Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\* |
    ForEach-Object {
    $progId = (Get-ItemProperty "$($_.PSParentPath)\$($_.PSChildName)\UserChoice" -ErrorAction SilentlyContinue).ProgId
    if ($progId) {
    "$($_.PSChildName), $progId"
    }
    }
    Write-Output $assocList
    }
    }
    function Get-PTA {
    [CmdletBinding()]
    param (
    [Parameter(Mandatory = $false)]
    [String]
    $Protocol
    )
    if ($Protocol) {
    Write-Verbose "Get Protocol Type Association for $Protocol"
    $assocFile = (Get-ItemProperty "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$Protocol\UserChoice"-ErrorAction SilentlyContinue).ProgId
    Write-Output $assocFile
    }
    else {
    Write-Verbose "Get Protocol Type Association List"
    $assocList = Get-ChildItem HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\* |
    ForEach-Object {
    $progId = (Get-ItemProperty "$($_.PSParentPath)\$($_.PSChildName)\UserChoice" -ErrorAction SilentlyContinue).ProgId
    if ($progId) {
    "$($_.PSChildName), $progId"
    }
    }
    Write-Output $assocList
    }
    }
    function Register-FTA {
    [CmdletBinding()]
    param (
    [Parameter( Position = 0, Mandatory = $true)]
    [ValidateScript( { Test-Path $_ })]
    [String]
    $ProgramPath,
    [Parameter( Position = 1, Mandatory = $true)]
    [Alias("Protocol")]
    [String]
    $Extension,
    [Parameter( Position = 2, Mandatory = $false)]
    [String]
    $ProgId,
    [Parameter( Position = 3, Mandatory = $false)]
    [String]
    $Icon
    )
    Write-Verbose "Register Application + Set Association"
    Write-Verbose "Application Path: $ProgramPath"
    if ($Extension.Contains(".")) {
    Write-Verbose "Extension: $Extension"
    }
    else {
    Write-Verbose "Protocol: $Extension"
    }
    if (!$ProgId) {
    $ProgId = "SFTA." + [System.IO.Path]::GetFileNameWithoutExtension($ProgramPath).replace(" ", "") + $Extension
    }
    $progCommand = """$ProgramPath"" ""%1"""
    Write-Verbose "ApplicationId: $ProgId"
    Write-Verbose "ApplicationCommand: $progCommand"
    try {
    $keyPath = "HKEY_CURRENT_USER\SOFTWARE\Classes\$Extension\OpenWithProgids"
    [Microsoft.Win32.Registry]::SetValue( $keyPath, $ProgId, ([byte[]]@()), [Microsoft.Win32.RegistryValueKind]::None)
    $keyPath = "HKEY_CURRENT_USER\SOFTWARE\Classes\$ProgId\shell\open\command"
    [Microsoft.Win32.Registry]::SetValue($keyPath, "", $progCommand)
    Write-Verbose "Register ProgId and ProgId Command OK"
    }
    catch {
    throw "Register ProgId and ProgId Command FAIL"
    }
    Set-FTA -ProgId $ProgId -Extension $Extension -Icon $Icon
    }
    function Remove-FTA {
    [CmdletBinding()]
    param (
    [Parameter(Mandatory = $true)]
    [Alias("ProgId")]
    [String]
    $ProgramPath,
    [Parameter(Mandatory = $true)]
    [String]
    $Extension
    )
    function local:Remove-UserChoiceKey {
    param (
    [Parameter( Position = 0, Mandatory = $True )]
    [String]
    $Key
    )
    $code = @'
    using System;
    using System.Runtime.InteropServices;
    using Microsoft.Win32;
    namespace Registry {
    public class Utils {
    [DllImport("advapi32.dll", SetLastError = true)]
    private static extern int RegOpenKeyEx(UIntPtr hKey, string subKey, int ulOptions, int samDesired, out UIntPtr hkResult);
    [DllImport("advapi32.dll", SetLastError=true, CharSet = CharSet.Unicode)]
    private static extern uint RegDeleteKey(UIntPtr hKey, string subKey);
    public static void DeleteKey(string key) {
    UIntPtr hKey = UIntPtr.Zero;
    RegOpenKeyEx((UIntPtr)0x80000001u, key, 0, 0x20019, out hKey);
    RegDeleteKey((UIntPtr)0x80000001u, key);
    }
    }
    }
    '@
    try {
    Add-Type -TypeDefinition $code
    }
    catch {}
    try {
    [Registry.Utils]::DeleteKey($Key)
    }
    catch {}
    }
    function local:Update-Registry {
    $code = @'
    [System.Runtime.InteropServices.DllImport("Shell32.dll")]
    private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
    public static void Refresh() {
    SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
    }
    '@
    try {
    Add-Type -MemberDefinition $code -Namespace SHChange -Name Notify
    }
    catch {}
    try {
    [SHChange.Notify]::Refresh()
    }
    catch {}
    }
    if (Test-Path -Path $ProgramPath) {
    $ProgId = "SFTA." + [System.IO.Path]::GetFileNameWithoutExtension($ProgramPath).replace(" ", "") + $Extension
    }
    else {
    $ProgId = $ProgramPath
    }
    try {
    $keyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice"
    Write-Verbose "Remove User UserChoice Key If Exist: $keyPath"
    Remove-UserChoiceKey $keyPath
    $keyPath = "HKCU:\SOFTWARE\Classes\$ProgId"
    Write-Verbose "Remove Key If Exist: $keyPath"
    Remove-Item -Path $keyPath -Recurse -ErrorAction Stop | Out-Null
    }
    catch {
    Write-Verbose "Key No Exist: $keyPath"
    }
    try {
    $keyPath = "HKCU:\SOFTWARE\Classes\$Extension\OpenWithProgids"
    Write-Verbose "Remove Property If Exist: $keyPath Property $ProgId"
    Remove-ItemProperty -Path $keyPath -Name $ProgId -ErrorAction Stop | Out-Null
    }
    catch {
    Write-Verbose "Property No Exist: $keyPath Property: $ProgId"
    }
    Update-Registry
    Write-Output "Removed: $ProgId"
    }
    function Set-FTA {
    [CmdletBinding()]
    param (
    [Parameter(Mandatory = $true)]
    [String]
    $ProgId,
    [Parameter(Mandatory = $true)]
    [Alias("Protocol")]
    [String]
    $Extension,
    [String]
    $Icon
    )
    if (Test-Path -Path $ProgId) {
    $ProgId = "SFTA." + [System.IO.Path]::GetFileNameWithoutExtension($ProgId).replace(" ", "") + $Extension
    }
    Write-Verbose "ProgId: $ProgId"
    Write-Verbose "Extension/Protocol: $Extension"
    function local:Update-RegistryChanges {
    $code = @'
    [System.Runtime.InteropServices.DllImport("Shell32.dll")]
    private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
    public static void Refresh() {
    SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
    }
    '@
    try {
    Add-Type -MemberDefinition $code -Namespace SHChange -Name Notify
    }
    catch {}
    try {
    [SHChange.Notify]::Refresh()
    }
    catch {}
    }
    function local:Set-Icon {
    param (
    [Parameter( Position = 0, Mandatory = $True )]
    [String]
    $ProgId,
    [Parameter( Position = 1, Mandatory = $True )]
    [String]
    $Icon
    )
    try {
    $keyPath = "HKEY_CURRENT_USER\SOFTWARE\Classes\$ProgId\DefaultIcon"
    [Microsoft.Win32.Registry]::SetValue($keyPath, "", $Icon)
    Write-Verbose "Write Reg Icon OK"
    Write-Verbose "Reg Icon: $keyPath"
    }
    catch {
    Write-Verbose "Write Reg Icon Fail"
    }
    }
    function local:Write-ExtensionKeys {
    param (
    [Parameter( Position = 0, Mandatory = $True )]
    [String]
    $ProgId,
    [Parameter( Position = 1, Mandatory = $True )]
    [String]
    $Extension,
    [Parameter( Position = 2, Mandatory = $True )]
    [String]
    $ProgHash
    )
    function local:Remove-UserChoiceKey {
    param (
    [Parameter( Position = 0, Mandatory = $True )]
    [String]
    $Key
    )
    $code = @'
    using System;
    using System.Runtime.InteropServices;
    using Microsoft.Win32;
    namespace Registry {
    public class Utils {
    [DllImport("advapi32.dll", SetLastError = true)]
    private static extern int RegOpenKeyEx(UIntPtr hKey, string subKey, int ulOptions, int samDesired, out UIntPtr hkResult);
    [DllImport("advapi32.dll", SetLastError=true, CharSet = CharSet.Unicode)]
    private static extern uint RegDeleteKey(UIntPtr hKey, string subKey);
    public static void DeleteKey(string key) {
    UIntPtr hKey = UIntPtr.Zero;
    RegOpenKeyEx((UIntPtr)0x80000001u, key, 0, 0x20019, out hKey);
    RegDeleteKey((UIntPtr)0x80000001u, key);
    }
    }
    }
    '@
    try {
    Add-Type -TypeDefinition $code
    }
    catch {}
    try {
    [Registry.Utils]::DeleteKey($Key)
    }
    catch {}
    }
    try {
    $keyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice"
    Write-Verbose "Remove Extension UserChoice Key If Exist: $keyPath"
    Remove-UserChoiceKey $keyPath
    }
    catch {
    Write-Verbose "Extension UserChoice Key No Exist: $keyPath"
    }
    try {
    $keyPath = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$Extension\UserChoice"
    [Microsoft.Win32.Registry]::SetValue($keyPath, "Hash", $ProgHash)
    [Microsoft.Win32.Registry]::SetValue($keyPath, "ProgId", $ProgId)
    Write-Verbose "Write Reg Extension UserChoice OK"
    }
    catch {
    throw "Write Reg Extension UserChoice FAIL"
    }
    }
    function local:Write-ProtocolKeys {
    param (
    [Parameter( Position = 0, Mandatory = $True )]
    [String]
    $ProgId,
    [Parameter( Position = 1, Mandatory = $True )]
    [String]
    $Protocol,
    [Parameter( Position = 2, Mandatory = $True )]
    [String]
    $ProgHash
    )
    try {
    $keyPath = "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$Protocol\UserChoice"
    Write-Verbose "Remove Protocol UserChoice Key If Exist: $keyPath"
    Remove-Item -Path $keyPath -Recurse -ErrorAction Stop | Out-Null
    }
    catch {
    Write-Verbose "Protocol UserChoice Key No Exist: $keyPath"
    }
    try {
    $keyPath = "HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\$Protocol\UserChoice"
    [Microsoft.Win32.Registry]::SetValue( $keyPath, "Hash", $ProgHash)
    [Microsoft.Win32.Registry]::SetValue($keyPath, "ProgId", $ProgId)
    Write-Verbose "Write Reg Protocol UserChoice OK"
    }
    catch {
    throw "Write Reg Protocol UserChoice FAIL"
    }
    }
    function local:Get-UserExperience {
    [OutputType([string])]
    $userExperienceSearch = "User Choice set via Windows User Experience"
    $user32Path = [Environment]::GetFolderPath([Environment+SpecialFolder]::SystemX86) + "\Shell32.dll"
    $fileStream = [System.IO.File]::Open($user32Path, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite)
    $binaryReader = New-Object System.IO.BinaryReader($fileStream)
    [Byte[]] $bytesData = $binaryReader.ReadBytes(5mb)
    $fileStream.Close()
    $dataString = [Text.Encoding]::Unicode.GetString($bytesData)
    $position1 = $dataString.IndexOf($userExperienceSearch)
    $position2 = $dataString.IndexOf("}", $position1)
    Write-Output $dataString.Substring($position1, $position2 - $position1 + 1)
    }
    function local:Get-UserSid {
    [OutputType([string])]
    $userSid = ((New-Object System.Security.Principal.NTAccount([Environment]::UserName)).Translate([System.Security.Principal.SecurityIdentifier]).value).ToLower()
    Write-Output $userSid
    }
    function local:Get-HexDateTime {
    [OutputType([string])]
    $now = [DateTime]::Now
    $dateTime = [DateTime]::New($now.Year, $now.Month, $now.Day, $now.Hour, $now.Minute, 0)
    $fileTime = $dateTime.ToFileTime()
    $hi = ($fileTime -shr 32)
    $low = ($fileTime -band 0xFFFFFFFFL)
    $dateTimeHex = ($hi.ToString("X8") + $low.ToString("X8")).ToLower()
    Write-Output $dateTimeHex
    }
    function Get-Hash {
    [CmdletBinding()]
    param (
    [Parameter( Position = 0, Mandatory = $True )]
    [string]
    $BaseInfo
    )
    function local:Get-ShiftRight {
    [CmdletBinding()]
    param (
    [Parameter( Position = 0, Mandatory = $true)]
    [long] $iValue,
    [Parameter( Position = 1, Mandatory = $true)]
    [int] $iCount
    )
    if ($iValue -band 0x80000000) {
    Write-Output (( $iValue -shr $iCount) -bxor 0xFFFF0000)
    }
    else {
    Write-Output ($iValue -shr $iCount)
    }
    }
    function local:Get-Long {
    [CmdletBinding()]
    param (
    [Parameter( Position = 0, Mandatory = $true)]
    [byte[]] $Bytes,
    [Parameter( Position = 1)]
    [int] $Index = 0
    )
    Write-Output ([BitConverter]::ToInt32($Bytes, $Index))
    }
    function local:Convert-Int32 {
    param (
    [Parameter( Position = 0, Mandatory = $true)]
    $Value
    )
    [byte[]] $bytes = [BitConverter]::GetBytes($Value)
    return [BitConverter]::ToInt32( $bytes, 0)
    }
    [Byte[]] $bytesBaseInfo = [System.Text.Encoding]::Unicode.GetBytes($baseInfo)
    $bytesBaseInfo += 0x00, 0x00
    $MD5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
    [Byte[]] $bytesMD5 = $MD5.ComputeHash($bytesBaseInfo)
    $lengthBase = ($baseInfo.Length * 2) + 2
    $length = (($lengthBase -band 4) -le 1) + (Get-ShiftRight $lengthBase 2) - 1
    $base64Hash = ""
    if ($length -gt 1) {
    $map = @{PDATA = 0; CACHE = 0; COUNTER = 0 ; INDEX = 0; MD51 = 0; MD52 = 0; OUTHASH1 = 0; OUTHASH2 = 0;
    R0 = 0; R1 = @(0, 0); R2 = @(0, 0); R3 = 0; R4 = @(0, 0); R5 = @(0, 0); R6 = @(0, 0); R7 = @(0, 0)
    }
    $map.CACHE = 0
    $map.OUTHASH1 = 0
    $map.PDATA = 0
    $map.MD51 = (((Get-Long $bytesMD5) -bor 1) + 0x69FB0000L)
    $map.MD52 = ((Get-Long $bytesMD5 4) -bor 1) + 0x13DB0000L
    $map.INDEX = Get-ShiftRight ($length - 2) 1
    $map.COUNTER = $map.INDEX + 1
    while ($map.COUNTER) {
    $map.R0 = Convert-Int32 ((Get-Long $bytesBaseInfo $map.PDATA) + [long]$map.OUTHASH1)
    $map.R1[0] = Convert-Int32 (Get-Long $bytesBaseInfo ($map.PDATA + 4))
    $map.PDATA = $map.PDATA + 8
    $map.R2[0] = Convert-Int32 (($map.R0 * ([long]$map.MD51)) - (0x10FA9605L * ((Get-ShiftRight $map.R0 16))))
    $map.R2[1] = Convert-Int32 ((0x79F8A395L * ([long]$map.R2[0])) + (0x689B6B9FL * (Get-ShiftRight $map.R2[0] 16)))
    $map.R3 = Convert-Int32 ((0xEA970001L * $map.R2[1]) - (0x3C101569L * (Get-ShiftRight $map.R2[1] 16) ))
    $map.R4[0] = Convert-Int32 ($map.R3 + $map.R1[0])
    $map.R5[0] = Convert-Int32 ($map.CACHE + $map.R3)
    $map.R6[0] = Convert-Int32 (($map.R4[0] * [long]$map.MD52) - (0x3CE8EC25L * (Get-ShiftRight $map.R4[0] 16)))
    $map.R6[1] = Convert-Int32 ((0x59C3AF2DL * $map.R6[0]) - (0x2232E0F1L * (Get-ShiftRight $map.R6[0] 16)))
    $map.OUTHASH1 = Convert-Int32 ((0x1EC90001L * $map.R6[1]) + (0x35BD1EC9L * (Get-ShiftRight $map.R6[1] 16)))
    $map.OUTHASH2 = Convert-Int32 ([long]$map.R5[0] + [long]$map.OUTHASH1)
    $map.CACHE = ([long]$map.OUTHASH2)
    $map.COUNTER = $map.COUNTER - 1
    }
    [Byte[]] $outHash = @(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
    [byte[]] $buffer = [BitConverter]::GetBytes($map.OUTHASH1)
    $buffer.CopyTo($outHash, 0)
    $buffer = [BitConverter]::GetBytes($map.OUTHASH2)
    $buffer.CopyTo($outHash, 4)
    $map = @{PDATA = 0; CACHE = 0; COUNTER = 0 ; INDEX = 0; MD51 = 0; MD52 = 0; OUTHASH1 = 0; OUTHASH2 = 0;
    R0 = 0; R1 = @(0, 0); R2 = @(0, 0); R3 = 0; R4 = @(0, 0); R5 = @(0, 0); R6 = @(0, 0); R7 = @(0, 0)
    }
    $map.CACHE = 0
    $map.OUTHASH1 = 0
    $map.PDATA = 0
    $map.MD51 = ((Get-Long $bytesMD5) -bor 1)
    $map.MD52 = ((Get-Long $bytesMD5 4) -bor 1)
    $map.INDEX = Get-ShiftRight ($length - 2) 1
    $map.COUNTER = $map.INDEX + 1
    while ($map.COUNTER) {
    $map.R0 = Convert-Int32 ((Get-Long $bytesBaseInfo $map.PDATA) + ([long]$map.OUTHASH1))
    $map.PDATA = $map.PDATA + 8
    $map.R1[0] = Convert-Int32 ($map.R0 * [long]$map.MD51)
    $map.R1[1] = Convert-Int32 ((0xB1110000L * $map.R1[0]) - (0x30674EEFL * (Get-ShiftRight $map.R1[0] 16)))
    $map.R2[0] = Convert-Int32 ((0x5B9F0000L * $map.R1[1]) - (0x78F7A461L * (Get-ShiftRight $map.R1[1] 16)))
    $map.R2[1] = Convert-Int32 ((0x12CEB96DL * (Get-ShiftRight $map.R2[0] 16)) - (0x46930000L * $map.R2[0]))
    $map.R3 = Convert-Int32 ((0x1D830000L * $map.R2[1]) + (0x257E1D83L * (Get-ShiftRight $map.R2[1] 16)))
    $map.R4[0] = Convert-Int32 ([long]$map.MD52 * ([long]$map.R3 + (Get-Long $bytesBaseInfo ($map.PDATA - 4))))
    $map.R4[1] = Convert-Int32 ((0x16F50000L * $map.R4[0]) - (0x5D8BE90BL * (Get-ShiftRight $map.R4[0] 16)))
    $map.R5[0] = Convert-Int32 ((0x96FF0000L * $map.R4[1]) - (0x2C7C6901L * (Get-ShiftRight $map.R4[1] 16)))
    $map.R5[1] = Convert-Int32 ((0x2B890000L * $map.R5[0]) + (0x7C932B89L * (Get-ShiftRight $map.R5[0] 16)))
    $map.OUTHASH1 = Convert-Int32 ((0x9F690000L * $map.R5[1]) - (0x405B6097L * (Get-ShiftRight ($map.R5[1]) 16)))
    $map.OUTHASH2 = Convert-Int32 ([long]$map.OUTHASH1 + $map.CACHE + $map.R3)
    $map.CACHE = ([long]$map.OUTHASH2)
    $map.COUNTER = $map.COUNTER - 1
    }
    $buffer = [BitConverter]::GetBytes($map.OUTHASH1)
    $buffer.CopyTo($outHash, 8)
    $buffer = [BitConverter]::GetBytes($map.OUTHASH2)
    $buffer.CopyTo($outHash, 12)
    [Byte[]] $outHashBase = @(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
    $hashValue1 = ((Get-Long $outHash 8) -bxor (Get-Long $outHash))
    $hashValue2 = ((Get-Long $outHash 12) -bxor (Get-Long $outHash 4))
    $buffer = [BitConverter]::GetBytes($hashValue1)
    $buffer.CopyTo($outHashBase, 0)
    $buffer = [BitConverter]::GetBytes($hashValue2)
    $buffer.CopyTo($outHashBase, 4)
    $base64Hash = [Convert]::ToBase64String($outHashBase)
    }
    Write-Output $base64Hash
    }
    Write-Verbose "Getting Hash For $ProgId $Extension"
    $userSid = Get-UserSid
    $userExperience = Get-UserExperience
    $userDateTime = Get-HexDateTime
    Write-Debug "UserDateTime: $userDateTime"
    Write-Debug "UserSid: $userSid"
    Write-Debug "UserExperience: $userExperience"
    $baseInfo = "$Extension$userSid$ProgId$userDateTime$userExperience".ToLower()
    Write-Verbose "baseInfo: $baseInfo"
    $progHash = Get-Hash $baseInfo
    Write-Verbose "Hash: $progHash"
    #Handle Extension Or Protocol
    if ($Extension.Contains(".")) {
    Write-Verbose "Write Registry Extension: $Extension"
    Write-ExtensionKeys $ProgId $Extension $progHash
    }
    else {
    Write-Verbose "Write Registry Protocol: $Extension"
    Write-ProtocolKeys $ProgId $Extension $progHash
    }
    if ($Icon) {
    Write-Verbose "Set Icon: $Icon"
    Set-Icon $ProgId $Icon
    }
    Update-RegistryChanges
    }
    function Set-PTA {
    [CmdletBinding()]
    param (
    [Parameter(Mandatory = $true)]
    [String]
    $ProgId,
    [Parameter(Mandatory = $true)]
    [String]
    $Protocol,
    [String]
    $Icon
    )
    Set-FTA -ProgId $ProgId -Protocol $Protocol -Icon $Icon
    }

    ::-------------------------------------------------------------------------------------------
    :: Function to unhide a Windows Component Package
    :: Input Parameters [ %~1 : Package Name ]
    ::-------------------------------------------------------------------------------------------
    :UnHidePackage
    setlocal
    Set-Variable RegistryKey=
    :: Retriving Package Registry Key Path
    for /f "tokens=* delims=" %%a in ('reg query "HKLM\TK_SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" /f "%~1" ^| find /I "%~1"') do ( Set-Variable "RegistryKey=%%a" )
    :: Making Windows Components Package visible
    reg add "%RegistryKey%" /v Visibility /t REG_DWORD /d 1 /f >nul 2>&1
    reg add "%RegistryKey%" /v DefVis /t REG_DWORD /d 2 /f >nul 2>&1
    reg delete "%RegistryKey%\Owners" /f >nul 2>&1
    Set-Variable RegistryKey=
    endlocal
    goto :eof
    ::-------------------------------------------------------------------------------------------
     
  13. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    #373 mdl052020, Jun 1, 2021
    Last edited: Jun 1, 2021
    (OP)
    Excellent @ahczwudichao Pl Keep it Up :p
    Edit :
    I Like the way you are trying best to contribute your script codes to this project which usually nobody else shared Except (Drew84 :worthy: as always being a first tester of New Updated Project) since a long.
    Thatswhy i am very very thankfull to you for your support & contribution.
     
  14. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    How many of my friends are waiting for latest updated June 2021 $OEM$ Pack to be updated only on our MDL community to first page of this thread.
     
  15. TesterMachineOS

    TesterMachineOS MDL Novice

    Apr 20, 2021
    31
    17
    0
    Does anyone know what services are necessary for the microsoft store to work?
     
  16. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    Pl ask it in Win10 Thread not here .

    Thanks & Regards.
     
  17. drew84

    drew84 MDL Addicted

    Mar 13, 2014
    956
    1,490
    30
    ... saw notification, ... imagine how disappointed I was to arrive here and see only the above :-(
     
  18. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    What happened Brother . Why Disappointed ?
     
  19. mdl052020

    mdl052020 MDL Member

    May 31, 2020
    1,047
    1,140
    60
    Very Bad to get only 6 Likes for me to share Latest Updated June 2021 $OEM$ Pack . Havent Expected such no of Least likes for $OEM$ June 2021 Pack to be Published.
     
  20. drew84

    drew84 MDL Addicted

    Mar 13, 2014
    956
    1,490
    30
    ... was expecting June 2021 $OEM$ Pack

    ... this suggests that it has been posted (shared), however I must be missing something, as I can't find it