mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-28 00:54:47 -05:00
Taskbaritem > Progressbar / Overlay icon / description / asset mgmt (#2309)
* Add Progress bar to some stuff https://learn.microsoft.com/en-us/dotnet/api/system.windows.shell.taskbariteminfo?view=windowsdesktop-8.0 * add function to manage taskbar item changed from manually setting the taskbar overlay, progressvalue and progress state to setting them through a function * add description feature * use Dispatcher.Invoke * restructure, fix, additions * fix merge conflicts * add check to progresses * remove progress from wiget & choco install * fix * polish * fix * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * fix syntax * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * rework - add overlay presets - rework image saving & converting - removed popup after uninstalling applications * fix description of function * undo winutil * remove check.png * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * Update functions/private/Set-WinUtilTaskbarItem.ps1 Co-authored-by: Mr.k <mineshtine28546271@gmail.com> * rework assets directory & its usage * fixes - ability to set no overlay added - added relative path to winutildir * hotfix * last fixes * add comment * remove trailing whitespaces THX to Mr.K :) * renamed checkmark & added warning * last fixes remove bitmap remove unneeded "| out-null" * hotfix for new commit --------- Co-authored-by: Mr.k <mineshtine28546271@gmail.com>
This commit is contained in:
@ -16,12 +16,18 @@ function Invoke-WPFFeatureInstall {
|
||||
|
||||
Invoke-WPFRunspace -ArgumentList $Features -DebugPreference $DebugPreference -ScriptBlock {
|
||||
param($Features, $DebugPreference)
|
||||
|
||||
$sync.ProcessRunning = $true
|
||||
if ($Features.count -eq 1){
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
|
||||
} else {
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
|
||||
}
|
||||
|
||||
Invoke-WinUtilFeatureInstall $Features
|
||||
|
||||
$sync.ProcessRunning = $false
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
|
||||
|
||||
Write-Host "==================================="
|
||||
Write-Host "--- Features are Installed ---"
|
||||
Write-Host "--- A Reboot may be required ---"
|
||||
|
@ -24,6 +24,7 @@ function Invoke-WPFGetInstalled {
|
||||
param($checkbox, $DebugPreference)
|
||||
|
||||
$sync.ProcessRunning = $true
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" })
|
||||
|
||||
if($checkbox -eq "winget"){
|
||||
Write-Host "Getting Installed Programs..."
|
||||
@ -42,5 +43,6 @@ function Invoke-WPFGetInstalled {
|
||||
|
||||
Write-Host "Done..."
|
||||
$sync.ProcessRunning = $false
|
||||
$sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "None" })
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ function Invoke-WPFGetIso {
|
||||
$sync.BusyText.Text="N Busy"
|
||||
|
||||
|
||||
|
||||
Write-Host " _ __ __ _ "
|
||||
Write-Host " /\/\ (_) ___ _ __ ___ / / /\ \ \(_) _ __ "
|
||||
Write-Host " / \ | | / __|| '__| / _ \ \ \/ \/ /| || '_ \ "
|
||||
@ -88,6 +89,8 @@ function Invoke-WPFGetIso {
|
||||
return
|
||||
}
|
||||
|
||||
Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo"
|
||||
|
||||
# Detect the file size of the ISO and compare it with the free space of the system drive
|
||||
$isoSize = (Get-Item -Path $filePath).Length
|
||||
Write-Debug "Size of ISO file: $($isoSize) bytes"
|
||||
@ -104,6 +107,7 @@ function Invoke-WPFGetIso {
|
||||
{
|
||||
# It's critical and we can't continue. Output an error
|
||||
Write-Host "You don't have enough space for this operation. You need at least $([Math]::Round(($isoSize / ([Math]::Pow(1024, 2))) * 2, 2)) MB of free space to copy the ISO files to a temp directory and to be able to perform additional operations."
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
return
|
||||
}
|
||||
else
|
||||
@ -122,6 +126,7 @@ function Invoke-WPFGetIso {
|
||||
Write-Error "Failed to mount the image. Error: $($_.Exception.Message)"
|
||||
Write-Error "This is NOT winutil's problem, your ISO might be corrupt, or there is a problem on the system"
|
||||
Write-Error "Please refer to this wiki for more details https://github.com/ChrisTitusTech/winutil/blob/main/wiki/Error-in-Winutil-MicroWin-during-ISO-mounting%2Cmd"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
return
|
||||
}
|
||||
# storing off values in hidden fields for further steps
|
||||
@ -199,6 +204,7 @@ function Invoke-WPFGetIso {
|
||||
$msg = "Neither install.wim nor install.esd exist in the image, this could happen if you use unofficial Windows images. Please don't use shady images from the internet, use only official images. Here are instructions how to download ISO images if the Microsoft website is not showing the link to download and ISO. https://www.techrepublic.com/article/how-to-download-a-windows-10-iso-file-without-using-the-media-creation-tool/"
|
||||
Write-Host $msg
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
throw
|
||||
}
|
||||
elseif ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -PathType Leaf))
|
||||
@ -239,6 +245,7 @@ function Invoke-WPFGetIso {
|
||||
|
||||
$sync.BusyMessage.Visibility="Hidden"
|
||||
$sync.ProcessRunning = $false
|
||||
Set-WinUtilTaskbaritem -state "None" -overlay "checkmark"
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,8 +20,14 @@ function Invoke-WPFInstall {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Invoke-WPFRunspace -ArgumentList $PackagesToInstall -DebugPreference $DebugPreference -ScriptBlock {
|
||||
param($PackagesToInstall, $DebugPreference)
|
||||
if ($PackagesToInstall.count -eq 1){
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
|
||||
} else {
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
|
||||
}
|
||||
$packagesWinget, $packagesChoco = {
|
||||
$packagesWinget = [System.Collections.Generic.List`1[System.Object]]::new()
|
||||
$packagesChoco = [System.Collections.Generic.List`1[System.Object]]::new()
|
||||
@ -52,13 +58,14 @@ function Invoke-WPFInstall {
|
||||
Write-Host "==========================================="
|
||||
Write-Host "-- Installs have finished ---"
|
||||
Write-Host "==========================================="
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
|
||||
}
|
||||
Catch {
|
||||
Write-Host "==========================================="
|
||||
Write-Host "Error: $_"
|
||||
Write-Host "==========================================="
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -overlay "warning" })
|
||||
}
|
||||
Start-Sleep -Seconds 5
|
||||
$sync.ProcessRunning = $False
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ function Invoke-WPFInstallUpgrade {
|
||||
return
|
||||
}
|
||||
|
||||
# Set-WinUtilTaskbaritem -state "Indeterminate"
|
||||
|
||||
Update-WinUtilProgramWinget
|
||||
|
||||
Write-Host "==========================================="
|
||||
|
@ -4,6 +4,7 @@ function Invoke-WPFMicrowin {
|
||||
Invoke MicroWin routines...
|
||||
#>
|
||||
|
||||
|
||||
if($sync.ProcessRunning) {
|
||||
$msg = "GetIso process is currently running."
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
||||
@ -39,9 +40,12 @@ public class PowerManagement {
|
||||
|
||||
if ($SaveDialog.FileName -eq "") {
|
||||
Write-Host "No file name for the target image was specified"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
return
|
||||
}
|
||||
|
||||
Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo"
|
||||
|
||||
Write-Host "Target ISO location: $($SaveDialog.FileName)"
|
||||
|
||||
$index = $sync.MicrowinWindowsFlavors.SelectedValue.Split(":")[0].Trim()
|
||||
@ -74,6 +78,7 @@ public class PowerManagement {
|
||||
$msg = "The export process has failed and MicroWin processing cannot continue"
|
||||
Write-Host "Failed to export the image"
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -87,6 +92,7 @@ public class PowerManagement {
|
||||
$dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers."
|
||||
Write-Host $msg
|
||||
[System.Windows.MessageBox]::Show($dlg_msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Exclamation)
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
return
|
||||
}
|
||||
|
||||
@ -95,6 +101,7 @@ public class PowerManagement {
|
||||
if (-not $mountDirExists -or -not $scratchDirExists)
|
||||
{
|
||||
Write-Error "Required directories '$mountDirExists' '$scratchDirExists' and do not exist."
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
return
|
||||
}
|
||||
|
||||
@ -109,6 +116,7 @@ public class PowerManagement {
|
||||
else
|
||||
{
|
||||
Write-Host "Could not mount image. Exiting..."
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
return
|
||||
}
|
||||
|
||||
@ -378,6 +386,7 @@ public class PowerManagement {
|
||||
if (-not (Test-Path -Path "$mountDir\sources\install.wim"))
|
||||
{
|
||||
Write-Error "Something went wrong and '$mountDir\sources\install.wim' doesn't exist. Please report this bug to the devs"
|
||||
Set-WinUtilTaskbaritem -state "Error" -value 1 -overlay "warning"
|
||||
return
|
||||
}
|
||||
Write-Host "Windows image completed. Continuing with boot.wim."
|
||||
@ -479,6 +488,7 @@ public class PowerManagement {
|
||||
#$msg = "Done. ISO image is located here: $env:temp\microwin.iso"
|
||||
$msg = "Done. ISO image is located here: $($SaveDialog.FileName)"
|
||||
Write-Host $msg
|
||||
Set-WinUtilTaskbaritem -state "None" -overlay "checkmark"
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Information)
|
||||
} else {
|
||||
Write-Host "ISO creation failed. The "$($mountDir)" directory has not been removed."
|
||||
|
@ -17,8 +17,8 @@ function Invoke-WPFShortcut {
|
||||
[bool]$RunAsAdmin = $false
|
||||
)
|
||||
|
||||
# add an a Custom Icon if it's available at "$env:TEMP\cttlogo.png", else don't add a Custom Icon.
|
||||
$iconPath = $null
|
||||
# Preper the Shortcut Fields and add an a Custom Icon if it's available, else don't add a Custom Icon.
|
||||
|
||||
Switch ($ShortcutToAdd) {
|
||||
"WinUtil" {
|
||||
# Use Powershell 7 if installed and fallback to PS5 if not
|
||||
@ -33,12 +33,6 @@ function Invoke-WPFShortcut {
|
||||
|
||||
$DestinationName = "WinUtil.lnk"
|
||||
|
||||
Invoke-WebRequest -Uri "https://christitus.com/images/logo-full.png" -OutFile "$env:TEMP\cttlogo.png"
|
||||
|
||||
if (Test-Path -Path "$env:TEMP\cttlogo.png") {
|
||||
$iconPath = "$env:LOCALAPPDATA\winutil\cttlogo.ico"
|
||||
ConvertTo-Icon -bitmapPath "$env:TEMP\cttlogo.png" -iconPath $iconPath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,10 +52,10 @@ function Invoke-WPFShortcut {
|
||||
# Prepare the Shortcut paramter
|
||||
$WshShell = New-Object -comObject WScript.Shell
|
||||
$Shortcut = $WshShell.CreateShortcut($FileBrowser.FileName)
|
||||
$Shortcut.TargetPath = $shell
|
||||
$Shortcut.Arguments = $shellArgs
|
||||
if ($null -ne $iconPath) {
|
||||
$shortcut.IconLocation = $iconPath
|
||||
$Shortcut.TargetPath = $SourceExe
|
||||
$Shortcut.Arguments = $ArgumentsToSourceExe
|
||||
if (Test-Path -Path $winutildir["logo.ico"]) {
|
||||
$shortcut.IconLocation = $winutildir["logo.ico"]
|
||||
}
|
||||
|
||||
# Save the Shortcut to disk
|
||||
|
@ -29,8 +29,14 @@ function Invoke-WPFUnInstall {
|
||||
|
||||
if($confirm -eq "No"){return}
|
||||
|
||||
|
||||
Invoke-WPFRunspace -ArgumentList $PackagesToInstall -DebugPreference $DebugPreference -ScriptBlock {
|
||||
param($PackagesToInstall, $DebugPreference)
|
||||
if ($PackagesToInstall.count -eq 1){
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
|
||||
} else {
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
|
||||
}
|
||||
$packagesWinget, $packagesChoco = {
|
||||
$packagesWinget = [System.Collections.Generic.List`1[System.Object]]::new()
|
||||
$packagesChoco = [System.Collections.Generic.List`1[System.Object]]::new()
|
||||
@ -56,22 +62,20 @@ function Invoke-WPFUnInstall {
|
||||
Install-WinUtilProgramChoco -ProgramsToInstall $packagesChoco -Manage "Uninstalling"
|
||||
}
|
||||
|
||||
$ButtonType = [System.Windows.MessageBoxButton]::OK
|
||||
$MessageboxTitle = "Uninstalls are Finished "
|
||||
$Messageboxbody = ("Done")
|
||||
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
||||
|
||||
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
||||
|
||||
Write-Host "==========================================="
|
||||
Write-Host "-- Uninstalls have finished ---"
|
||||
Write-Host "==========================================="
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
|
||||
}
|
||||
Catch {
|
||||
Write-Host "==========================================="
|
||||
Write-Host "Error: $_"
|
||||
Write-Host "==========================================="
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" -overlay "warning" })
|
||||
}
|
||||
$sync.ProcessRunning = $False
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -30,15 +30,22 @@ function Invoke-WPFtweaksbutton {
|
||||
|
||||
$sync.ProcessRunning = $true
|
||||
|
||||
if ($Tweaks.count -eq 1){
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
|
||||
} else {
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
|
||||
}
|
||||
$cnt = 0
|
||||
# Execute other selected tweaks
|
||||
foreach ($tweak in $Tweaks) {
|
||||
Write-Debug "This is a tweak to run $tweak count: $cnt"
|
||||
Invoke-WinUtilTweaks $tweak
|
||||
$cnt += 1
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($cnt/$Tweaks.Count) })
|
||||
}
|
||||
|
||||
$sync.ProcessRunning = $false
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
|
||||
Write-Host "================================="
|
||||
Write-Host "-- Tweaks are Finished ---"
|
||||
Write-Host "================================="
|
||||
|
@ -24,12 +24,21 @@ function Invoke-WPFundoall {
|
||||
param($Tweaks, $DebugPreference)
|
||||
|
||||
$sync.ProcessRunning = $true
|
||||
if ($Tweaks.count -eq 1){
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
|
||||
} else {
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
|
||||
}
|
||||
$cnt = 0
|
||||
|
||||
Foreach ($tweak in $tweaks){
|
||||
Invoke-WinUtilTweaks $tweak -undo $true
|
||||
$cnt += 1
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($cnt/$Tweaks.Count) })
|
||||
}
|
||||
|
||||
$sync.ProcessRunning = $false
|
||||
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
|
||||
Write-Host "=================================="
|
||||
Write-Host "--- Undo Tweaks are Finished ---"
|
||||
Write-Host "=================================="
|
||||
|
Reference in New Issue
Block a user