mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-01 18:42:35 -05:00
use Dispatcher.Invoke
This commit is contained in:
@ -14,19 +14,19 @@ function Install-WinUtilChoco {
|
||||
return
|
||||
}
|
||||
|
||||
Set-WinUtilTaskbaritem -state "Indeterminate"
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" })
|
||||
|
||||
Write-Host "Seems Chocolatey is not installed, installing now."
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) -ErrorAction Stop
|
||||
powershell choco feature enable -n allowGlobalConfirmation
|
||||
Set-WinUtilTaskbaritem -state "None"
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" })
|
||||
|
||||
}
|
||||
Catch {
|
||||
Write-Host "===========================================" -Foregroundcolor Red
|
||||
Write-Host "-- Chocolatey failed to install ---" -Foregroundcolor Red
|
||||
Write-Host "===========================================" -Foregroundcolor Red
|
||||
Set-WinUtilTaskbaritem -state "Error"
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ function Install-WinUtilProgramChoco {
|
||||
}
|
||||
}
|
||||
$x++
|
||||
# Set-WinUtilTaskbaritem -state "Normal" -value $x/$count
|
||||
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value $using:x/$using:count })
|
||||
}
|
||||
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
|
||||
|
||||
|
@ -97,7 +97,7 @@ Function Install-WinUtilProgramWinget {
|
||||
}
|
||||
}
|
||||
$X++
|
||||
# Set-WinUtilTaskbaritem -state "Normal" -value $x/$count
|
||||
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value $using:x/$using:count })
|
||||
}
|
||||
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
|
||||
return $failedPackages;
|
||||
|
@ -19,7 +19,7 @@ function Install-WinUtilWinget {
|
||||
Write-Host "`nWinget is not Installed. Continuing with install.`r" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Set-WinUtilTaskbaritem -state "Indeterminate"
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" })
|
||||
|
||||
# Gets the computer's information
|
||||
if ($null -eq $sync.ComputerInfo){
|
||||
@ -65,6 +65,6 @@ function Install-WinUtilWinget {
|
||||
throw [WingetFailedInstall]::new('Failed to install!')
|
||||
}
|
||||
}
|
||||
Set-WinUtilTaskbaritem -state "None"
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" })
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ function Invoke-WinUtilFeatureInstall {
|
||||
$CheckBox
|
||||
)
|
||||
|
||||
Set-WinUtilTaskbaritem -state "Normal" -value 1
|
||||
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 1/$using:CheckBox.Count })
|
||||
|
||||
$CheckBox | ForEach-Object {
|
||||
if($sync.configs.feature.$psitem.feature){
|
||||
@ -39,6 +39,7 @@ function Invoke-WinUtilFeatureInstall {
|
||||
|
||||
Write-Host "Running Script for $psitem"
|
||||
Invoke-Command $scriptblock -ErrorAction stop
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" })
|
||||
}
|
||||
Catch{
|
||||
if ($psitem.Exception.Message -like "*requires elevation*"){
|
||||
@ -46,7 +47,7 @@ function Invoke-WinUtilFeatureInstall {
|
||||
}
|
||||
|
||||
else{
|
||||
Set-WinUtilTaskbaritem -state "Error"
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
|
||||
Write-Warning "Unable to Install $feature due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
@ -54,7 +55,4 @@ function Invoke-WinUtilFeatureInstall {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sync["Form"].taskbarItemInfo.ProgressState -ne "Error"){
|
||||
Set-WinUtilTaskbaritem -state "None"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user