mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2025-11-17 11:06:18 +00:00
* Fix: Use regex replace to avoid #174 * Fix: Also fix root cause of Raphire#174 in start menu replacement * Fix missing backslash --------- Co-authored-by: Jeffrey <9938813+Raphire@users.noreply.github.com>
This commit is contained in:
@@ -531,7 +531,7 @@ function RegImport {
|
||||
reg import "$PSScriptRoot\Regfiles\$path"
|
||||
}
|
||||
else {
|
||||
$defaultUserPath = $env:USERPROFILE.Replace($env:USERNAME, 'Default\NTUSER.DAT')
|
||||
$defaultUserPath = $env:USERPROFILE -Replace ('\\' + $env:USERNAME + '$'), '\Default\NTUSER.DAT'
|
||||
|
||||
reg load "HKU\Default" $defaultUserPath | Out-Null
|
||||
reg import "$PSScriptRoot\Regfiles\Sysprep\$path"
|
||||
@@ -575,7 +575,7 @@ function ReplaceStartMenuForAllUsers {
|
||||
}
|
||||
|
||||
# Get path to start menu file for all users
|
||||
$userPathString = $env:USERPROFILE.Replace($env:USERNAME, "*\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState")
|
||||
$userPathString = $env:USERPROFILE -Replace ('\\' + $env:USERNAME + '$'), "\*\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState"
|
||||
$usersStartMenuPaths = get-childitem -path $userPathString
|
||||
|
||||
# Go through all users and replace the start menu file
|
||||
@@ -584,7 +584,7 @@ function ReplaceStartMenuForAllUsers {
|
||||
}
|
||||
|
||||
# Also replace the start menu file for the default user profile
|
||||
$defaultStartMenuPath = $env:USERPROFILE.Replace($env:USERNAME, 'Default\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState')
|
||||
$defaultStartMenuPath = $env:USERPROFILE -Replace ('\\' + $env:USERNAME + '$'), '\Default\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState'
|
||||
|
||||
# Create folder if it doesn't exist
|
||||
if (-not(Test-Path $defaultStartMenuPath)) {
|
||||
@@ -757,7 +757,7 @@ else {
|
||||
}
|
||||
|
||||
if ($global:Params.ContainsKey("Sysprep")) {
|
||||
$defaultUserPath = $env:USERPROFILE.Replace($env:USERNAME, 'Default\NTUSER.DAT')
|
||||
$defaultUserPath = $env:USERPROFILE -Replace ('\\' + $env:USERNAME + '$'), '\Default\NTUSER.DAT'
|
||||
|
||||
# Exit script if default user directory or NTUSER.DAT file cannot be found
|
||||
if (-not (Test-Path "$defaultUserPath")) {
|
||||
|
||||
Reference in New Issue
Block a user