mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-05-25 23:26:17 +00:00
Remove unused variables in ImportRegistryFile
This commit is contained in:
@@ -9,7 +9,6 @@ function ImportRegistryFile {
|
|||||||
|
|
||||||
$usesOfflineHive = $script:Params.ContainsKey("Sysprep") -or $script:Params.ContainsKey("User")
|
$usesOfflineHive = $script:Params.ContainsKey("Sysprep") -or $script:Params.ContainsKey("User")
|
||||||
$hiveDatPath = $null
|
$hiveDatPath = $null
|
||||||
$loadedHivePath = $null
|
|
||||||
$regFileDirectory = if ($usesOfflineHive) {
|
$regFileDirectory = if ($usesOfflineHive) {
|
||||||
Join-Path $script:RegfilesPath "Sysprep"
|
Join-Path $script:RegfilesPath "Sysprep"
|
||||||
}
|
}
|
||||||
@@ -35,7 +34,6 @@ function ImportRegistryFile {
|
|||||||
# Sysprep targets Default user, User targets the specified user
|
# Sysprep targets Default user, User targets the specified user
|
||||||
$targetUserName = if ($script:Params.ContainsKey("Sysprep")) { "Default" } else { $script:Params.Item("User") }
|
$targetUserName = if ($script:Params.ContainsKey("Sysprep")) { "Default" } else { $script:Params.Item("User") }
|
||||||
$hiveDatPath = GetUserDirectory -userName $targetUserName -fileName "NTUSER.DAT"
|
$hiveDatPath = GetUserDirectory -userName $targetUserName -fileName "NTUSER.DAT"
|
||||||
$loadedHivePath = 'HKEY_USERS\Default'
|
|
||||||
|
|
||||||
$global:LASTEXITCODE = 0
|
$global:LASTEXITCODE = 0
|
||||||
reg load "HKU\Default" $hiveDatPath | Out-Null
|
reg load "HKU\Default" $hiveDatPath | Out-Null
|
||||||
@@ -54,7 +52,6 @@ function ImportRegistryFile {
|
|||||||
Output = @()
|
Output = @()
|
||||||
ExitCode = 0
|
ExitCode = 0
|
||||||
Error = $null
|
Error = $null
|
||||||
FailureStage = $null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -68,14 +65,10 @@ function ImportRegistryFile {
|
|||||||
$result.ExitCode = $importExitCode
|
$result.ExitCode = $importExitCode
|
||||||
|
|
||||||
if ($importExitCode -ne 0) {
|
if ($importExitCode -ne 0) {
|
||||||
$result.FailureStage = 'import'
|
|
||||||
throw "Registry import failed with exit code $importExitCode for '$targetRegFilePath'"
|
throw "Registry import failed with exit code $importExitCode for '$targetRegFilePath'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
if (-not $result.FailureStage) {
|
|
||||||
$result.FailureStage = 'unknown'
|
|
||||||
}
|
|
||||||
$result.Error = $_.Exception.Message
|
$result.Error = $_.Exception.Message
|
||||||
$result.ExitCode = if ($LASTEXITCODE -ne 0) { $LASTEXITCODE } else { 1 }
|
$result.ExitCode = if ($LASTEXITCODE -ne 0) { $LASTEXITCODE } else { 1 }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user