diff --git a/Regfiles/Sysprep/Uninstall_Microsoft_Edge.reg b/Regfiles/Sysprep/Uninstall_Microsoft_Edge.reg new file mode 100644 index 0000000..ba0e3ca --- /dev/null +++ b/Regfiles/Sysprep/Uninstall_Microsoft_Edge.reg @@ -0,0 +1,4 @@ +Windows Registry Editor Version 5.00 + +[hkey_users\default\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce] +"UninstallMicrosoftEdge"="cmd.exe /c winget uninstall --accept-source-agreements --disable-interactivity --id Microsoft.Edge" diff --git a/Regfiles/Sysprep/Uninstall_Microsoft_OneDrive.reg b/Regfiles/Sysprep/Uninstall_Microsoft_OneDrive.reg new file mode 100644 index 0000000..10669e4 --- /dev/null +++ b/Regfiles/Sysprep/Uninstall_Microsoft_OneDrive.reg @@ -0,0 +1,4 @@ +Windows Registry Editor Version 5.00 + +[hkey_users\default\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce] +"UninstallMicrosoftOneDrive"="cmd.exe /c winget uninstall --accept-source-agreements --disable-interactivity --id Microsoft.OneDrive" diff --git a/Win11Debloat.ps1 b/Win11Debloat.ps1 index 534c4f5..bd13ed7 100755 --- a/Win11Debloat.ps1 +++ b/Win11Debloat.ps1 @@ -383,8 +383,18 @@ function RemoveApps { Write-Host "Error: WinGet is either not installed or is outdated, $app could not be removed" -ForegroundColor Red } else { - # Uninstall app via winget - Strip-Progress -ScriptBlock { winget uninstall --accept-source-agreements --disable-interactivity --id $app } | Tee-Object -Variable wingetOutput + $appName = $app -replace '\.', '_' + + # Uninstall app via winget, or create a scheduled task to uninstall it later + if ($script:Params.ContainsKey("User")) { + RegImport "Adding scheduled task to uninstall $app for user $(GetUserName)..." "Uninstall_$($appName).reg" + } + elseif ($script:Params.ContainsKey("Sysprep")) { + RegImport "Adding scheduled task to uninstall $app after new users log in..." "Uninstall_$($appName).reg" + } + else { + Strip-Progress -ScriptBlock { winget uninstall --accept-source-agreements --disable-interactivity --id $app } | Tee-Object -Variable wingetOutput + } If (($app -eq "Microsoft.Edge") -and (Select-String -InputObject $wingetOutput -Pattern "Uninstall failed with exit code")) { Write-Host "Unable to uninstall Microsoft Edge via Winget" -ForegroundColor Red