mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2025-11-17 02:56:17 +00:00
Added timeout to loading appslist from winget (#44)
This commit is contained in:
@@ -90,8 +90,18 @@ function ShowAppSelectionForm {
|
|||||||
$listOfApps = ""
|
$listOfApps = ""
|
||||||
|
|
||||||
if ($onlyInstalledCheckBox.Checked -and ($global:wingetInstalled -eq $true)) {
|
if ($onlyInstalledCheckBox.Checked -and ($global:wingetInstalled -eq $true)) {
|
||||||
# Get list of installed apps via winget
|
# Attempt to get a list of installed apps via winget, times out after 10 seconds
|
||||||
$listOfApps = winget list --accept-source-agreements --disable-interactivity
|
$job = Start-Job { return winget list --accept-source-agreements --disable-interactivity }
|
||||||
|
$jobDone = $job | Wait-Job -TimeOut 10
|
||||||
|
|
||||||
|
if (-not $jobDone) {
|
||||||
|
# Show error that the script was unable to get list of apps from winget
|
||||||
|
[System.Windows.MessageBox]::Show('Unable to load list of installed apps via winget, some apps may not be displayed in the list.','Error','Ok','Error')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Add output of job (list of apps) to $listOfApps
|
||||||
|
$listOfApps = Receive-Job -Job $job
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Go through appslist and add items one by one to the selectionBox
|
# Go through appslist and add items one by one to the selectionBox
|
||||||
@@ -270,7 +280,7 @@ function RemoveApps {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Uninstall app via winget
|
# Uninstall app via winget
|
||||||
winget uninstall --accept-source-agreements --id $app
|
winget uninstall --accept-source-agreements --disable-interactivity --id $app
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -424,11 +434,10 @@ function PrintFromFile {
|
|||||||
|
|
||||||
|
|
||||||
# Check if winget is installed
|
# Check if winget is installed
|
||||||
try {
|
if (Get-AppxPackage -Name "*Microsoft.DesktopAppInstaller*") {
|
||||||
$global:wingetVersion = winget -v
|
|
||||||
$global:wingetInstalled = $true
|
$global:wingetInstalled = $true
|
||||||
}
|
}
|
||||||
catch {
|
else {
|
||||||
$global:wingetInstalled = $false
|
$global:wingetInstalled = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user