mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-05-18 11:46:18 +00:00
Starting from this commit, Win11Debloat will automatically create a registry backup every time the script is run. This registry backup can be used to revert any registry changes made by the script.
45 lines
1.2 KiB
PowerShell
45 lines
1.2 KiB
PowerShell
function Split-RegistryPath {
|
|
param(
|
|
[Parameter(Mandatory)]
|
|
[string]$path
|
|
)
|
|
|
|
if ($path -notmatch '^(?<hive>HKEY_[^\\]+)(?:\\(?<subKey>.*))?$') {
|
|
return $null
|
|
}
|
|
|
|
return [PSCustomObject]@{
|
|
Hive = $matches.hive
|
|
SubKey = $matches.subKey
|
|
}
|
|
}
|
|
|
|
function Get-RegistryRootKey {
|
|
param(
|
|
[Parameter(Mandatory)]
|
|
[string]$hiveName
|
|
)
|
|
|
|
switch ($hiveName.ToUpperInvariant()) {
|
|
'HKEY_CURRENT_USER' { return [Microsoft.Win32.Registry]::CurrentUser }
|
|
'HKEY_LOCAL_MACHINE' { return [Microsoft.Win32.Registry]::LocalMachine }
|
|
'HKEY_CLASSES_ROOT' { return [Microsoft.Win32.Registry]::ClassesRoot }
|
|
'HKEY_USERS' { return [Microsoft.Win32.Registry]::Users }
|
|
'HKEY_CURRENT_CONFIG' { return [Microsoft.Win32.Registry]::CurrentConfig }
|
|
default { return $null }
|
|
}
|
|
}
|
|
|
|
function Get-RegistryFilePathForFeature {
|
|
param(
|
|
[Parameter(Mandatory)]
|
|
$Feature
|
|
)
|
|
|
|
if ($script:Params.ContainsKey('Sysprep') -or $script:Params.ContainsKey('User')) {
|
|
return Join-Path (Join-Path $script:RegfilesPath 'Sysprep') $Feature.RegistryKey
|
|
}
|
|
|
|
return Join-Path $script:RegfilesPath $Feature.RegistryKey
|
|
}
|