mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-07-03 07:08:27 +00:00
Fix Start Menu apps not being set correctly for all users when running script for other user (#637)
This commit is contained in:
@@ -92,13 +92,15 @@ function ExecuteParameter {
|
|||||||
}
|
}
|
||||||
'ClearStart' {
|
'ClearStart' {
|
||||||
Write-Host "> $($feature.ApplyText) for user $(GetUserName)..."
|
Write-Host "> $($feature.ApplyText) for user $(GetUserName)..."
|
||||||
ReplaceStartMenu
|
$startMenuBinFile = GetStartMenuBinPathForUser -UserName (GetUserName)
|
||||||
|
ReplaceStartMenu -startMenuBinFile $startMenuBinFile
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
'ReplaceStart' {
|
'ReplaceStart' {
|
||||||
Write-Host "> $($feature.ApplyText) for user $(GetUserName)..."
|
Write-Host "> $($feature.ApplyText) for user $(GetUserName)..."
|
||||||
ReplaceStartMenu $script:Params.Item("ReplaceStart")
|
$startMenuBinFile = GetStartMenuBinPathForUser -UserName (GetUserName)
|
||||||
|
ReplaceStartMenu -startMenuBinFile $startMenuBinFile -startMenuTemplate $script:Params.Item("ReplaceStart")
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -107,7 +109,7 @@ function ExecuteParameter {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
'ReplaceStartAllUsers' {
|
'ReplaceStartAllUsers' {
|
||||||
ReplaceStartMenuForAllUsers $script:Params.Item("ReplaceStartAllUsers")
|
ReplaceStartMenuForAllUsers -startMenuTemplate $script:Params.Item("ReplaceStartAllUsers")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
'DisableStoreSearchSuggestions' {
|
'DisableStoreSearchSuggestions' {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Credit: https://lazyadmin.nl/win-11/customize-windows-11-start-menu-layout/
|
# Credit: https://lazyadmin.nl/win-11/customize-windows-11-start-menu-layout/
|
||||||
function ReplaceStartMenuForAllUsers {
|
function ReplaceStartMenuForAllUsers {
|
||||||
param (
|
param (
|
||||||
$startMenuTemplate = "$script:AssetsPath\Start\start2.bin"
|
[string]$startMenuTemplate = "$script:AssetsPath\Start\start2.bin"
|
||||||
)
|
)
|
||||||
|
|
||||||
Write-Host "> Removing all pinned apps from the start menu for all users..."
|
Write-Host "> Removing all pinned apps from the start menu for all users..."
|
||||||
@@ -20,7 +20,7 @@ function ReplaceStartMenuForAllUsers {
|
|||||||
|
|
||||||
# Go through all users and replace the start menu file
|
# Go through all users and replace the start menu file
|
||||||
ForEach ($startMenuPath in $usersStartMenuPaths) {
|
ForEach ($startMenuPath in $usersStartMenuPaths) {
|
||||||
ReplaceStartMenu $startMenuTemplate "$($startMenuPath.Fullname)\start2.bin"
|
ReplaceStartMenu -startMenuBinFile "$($startMenuPath.Fullname)\start2.bin" -startMenuTemplate $startMenuTemplate
|
||||||
}
|
}
|
||||||
|
|
||||||
# Also replace the start menu file for the default user profile
|
# Also replace the start menu file for the default user profile
|
||||||
@@ -33,7 +33,7 @@ function ReplaceStartMenuForAllUsers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Copy template to default profile
|
# Copy template to default profile
|
||||||
Copy-Item -Path $startMenuTemplate -Destination $defaultStartMenuPath -Force
|
ReplaceStartMenu -startMenuBinFile "$($defaultStartMenuPath)\start2.bin" -startMenuTemplate $startMenuTemplate
|
||||||
Write-Host "Replaced start menu for the default user profile"
|
Write-Host "Replaced start menu for the default user profile"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
}
|
}
|
||||||
@@ -43,22 +43,18 @@ function ReplaceStartMenuForAllUsers {
|
|||||||
# Credit: https://lazyadmin.nl/win-11/customize-windows-11-start-menu-layout/
|
# Credit: https://lazyadmin.nl/win-11/customize-windows-11-start-menu-layout/
|
||||||
function ReplaceStartMenu {
|
function ReplaceStartMenu {
|
||||||
param (
|
param (
|
||||||
$startMenuTemplate = "$script:AssetsPath\Start\start2.bin",
|
[Parameter(Mandatory)]
|
||||||
$startMenuBinFile = "$env:LOCALAPPDATA\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start2.bin"
|
[string]$startMenuBinFile,
|
||||||
|
[string]$startMenuTemplate = "$script:AssetsPath\Start\start2.bin"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Change path to correct user if a user was specified
|
|
||||||
if ($script:Params.ContainsKey("User")) {
|
|
||||||
$startMenuBinFile = GetStartMenuBinPathForUser -UserName (GetUserName)
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if template bin file exists
|
# Check if template bin file exists
|
||||||
if (-not (Test-Path $startMenuTemplate)) {
|
if (-not (Test-Path $startMenuTemplate)) {
|
||||||
Write-Host "Error: Unable to replace start menu, template file not found" -ForegroundColor Red
|
Write-Host "Error: Unable to replace start menu, template file not found" -ForegroundColor Red
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([IO.Path]::GetExtension($startMenuTemplate) -ne ".bin" ) {
|
if ([IO.Path]::GetExtension($startMenuTemplate) -ne ".bin") {
|
||||||
Write-Host "Error: Unable to replace start menu, template file is not a valid .bin file" -ForegroundColor Red
|
Write-Host "Error: Unable to replace start menu, template file is not a valid .bin file" -ForegroundColor Red
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -113,7 +109,6 @@ function RestoreStartMenuFromBackup {
|
|||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[string]$StartMenuBinFile,
|
[string]$StartMenuBinFile,
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[string]$BackupFilePath
|
[string]$BackupFilePath
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -157,7 +152,6 @@ function RestoreStartMenuFromBackup {
|
|||||||
|
|
||||||
function RestoreStartMenu {
|
function RestoreStartMenu {
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[string]$BackupFilePath
|
[string]$BackupFilePath
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -171,7 +165,6 @@ function RestoreStartMenu {
|
|||||||
|
|
||||||
function RestoreStartMenuForAllUsers {
|
function RestoreStartMenuForAllUsers {
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[string]$BackupFilePath
|
[string]$BackupFilePath
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
function Show-RestoreBackupDialog {
|
function Show-RestoreBackupDialog {
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[System.Windows.Window]$Owner = $null
|
[System.Windows.Window]$Owner = $null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
function Show-RestoreBackupWindow {
|
function Show-RestoreBackupWindow {
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $false)]
|
|
||||||
[System.Windows.Window]$Owner = $null
|
[System.Windows.Window]$Owner = $null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user