Compare commits

..

7 Commits

Author SHA1 Message Date
27792dc8a3 use Dispatcher.Invoke 2024-07-13 12:54:59 +02:00
790e0b22a5 add description feature 2024-07-12 16:40:45 +02:00
73973d7101 add function to manage taskbar item
changed from manually setting the taskbar overlay, progressvalue and progress state to setting them through a function
2024-07-12 08:00:32 +02:00
a86b07a826 Add Progress bar to some stuff
https://learn.microsoft.com/en-us/dotnet/api/system.windows.shell.taskbariteminfo?view=windowsdesktop-8.0
2024-07-09 00:52:24 +02:00
b47036630c Move Launch Issues from ReadMe to Known Issues (#2222)
* remove launching issues from ReadME

* Add Launch Issues to Known Issues

* Relayout some stuff

---------

Co-authored-by: Chris Titus <contact@christitus.com>
2024-06-29 08:08:23 -05:00
e5ca44a0bd Improvements/Fixes for the Release Actions (#2221)
* add pre to tag to distinguish from full release

* explicitly serach for the newest pre-release

* set latest tag for releases
2024-06-29 06:46:52 -05:00
e7d49fe48b Pump up the value of 'operations-per-run' Field for 'Close Old Issues' Workflow (#2219)
Provides more 'head-room' for the 'stale' Actions to process all available Issues,
as well as PRs.. because they're processed no matter what, and I can't force this action not to.. as far as I know.
2024-06-29 06:45:29 -05:00
21 changed files with 6275 additions and 6059 deletions

View File

@ -30,6 +30,10 @@ jobs:
# Sends a message for both the Stale and Close events of an issue.
stale-issue-message: "This issue was marked as stale because it has been inactive for 7 days"
close-issue-message: "This issue was closed because it has been inactive for 7 days since it was marked as stale"
# Increase this value if the project receives a lot of
# PRs (yes.. apparently they're processed no matter what) & Issues.
# Default value for it (according to the docs) is 30
operations-per-run: 100
# Make this field equal true if you want to test your configuration if it works correctly or not
debug-only: false
repo-token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -22,7 +22,7 @@ jobs:
$version = ''
Get-Content ./winutil.ps1 -TotalCount 30 | ForEach-Object {
if ($_ -match 'Version\s*:\s*(\d{2}\.\d{2}\.\d{2})') {
$version = $matches[1]
$version = "pre"+$matches[1]
echo "version=$version" >> $GITHUB_ENV
echo "::set-output name=version::$version"
break

View File

@ -38,5 +38,6 @@ jobs:
name: Release ${{ steps.extract_version.outputs.version }}
files: ./winutil.ps1
prerelease: false
make_latest: "true"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,4 +1,37 @@
## Known Issues and Fixes
### Launch Issues:
- Windows Security (formerly Defender) and other anti-virus software are known to block the script. The script gets flagged due to the fact that it requires administrator privileges & makes drastic system changes.
- If possible: Allow script in Anti-Virus software settings.
- If you are having TLS 1.2 issues, or are having trouble resolving `christitus.com/win` then run with the following command:
```
[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;iex(New-Object Net.WebClient).DownloadString('https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1')
```
- If you are unable to resolve `christitus.com/win` and are getting errors launching the tool, it might be due to India blocking GitHub's content domain and preventing downloads.
- Source: <https://timesofindia.indiatimes.com/gadgets-news/github-content-domain-blocked-for-these-indian-users-reports/articleshow/96687992.cms>
If you are still having issues try using a **VPN**, or changing your **DNS provider** to:
| `1.1.1.1` | `1.0.0.1` | or | `8.8.8.8` | `8.8.4.4` |
|---------|---------|-----|---------|---------|
- Script doesn't run/PowerShell crashes:
1. Press Windows Key+X and select 'PowerShell (Admin)' (Windows 10) or 'Windows Terminal (Admin)' (Windows 11)
2. Run:
```
Set-ExecutionPolicy Unrestricted -Scope Process -Force
```
3. Run:
```
irm christitus.com/win | iex
```
### Other Issues:
- Windows taking longer to shut down:
- [#69](https://github.com/ChrisTitusTech/winutil/issues/69) Turn on fast startup: Press Windows key + R, then type:
```
@ -16,6 +49,9 @@ Get-Service -Name "XboxGipSvc" | Set-Service -StartupType Automatic
- Winget requires interaction on first run: Manually type 'y' and 'enter' into the PowerShell console to continue
- (Windows 11) Quick Settings no longer works: Launch the Script and click 'Enable Action Center'
- Explorer no longer launches: Go to Control Panel, File Explorer Options, Change the 'Open File Explorer to' option to 'This PC'.
- Script doesn't run/PowerShell crashes:
1. Press Windows Key+X and select 'PowerShell (Admin)' (Windows 10) or 'Windows Terminal (Admin)' (Windows 11)
2. Run:
@ -25,4 +61,4 @@ Get-Service -Name "XboxGipSvc" | Set-Service -StartupType Automatic
3. Run:
```
irm christitus.com/win | iex
```
```

View File

@ -34,6 +34,9 @@ If this site is not reachable from your country, please try running it directly
irm "https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1" | iex
```
If you still have Issues, refer to [Known Issues](https://github.com/ChrisTitusTech/winutil/blob/main/KnownIssues.md).
#### Automation
Some features are available through automation. This allows you to save your config file pass it to Winutil walk away and come back to a finished system. Here is how you can set it up currently with Winutil >24.01.15
@ -52,21 +55,6 @@ iex "& { $(irm christitus.com/win) } -Config [path-to-your-config] -Run"
7. Have a cup of coffee! Come back when it's done.
## Issues:
- If you are unable to resolve christitus.com/win and are getting errors launching the tool, it might be due to India blocking GitHub's content domain and preventing downloads. You may use a VPN or change your DNS provider to Google/Cloudflare/etc.
Source: <https://timesofindia.indiatimes.com/gadgets-news/github-content-domain-blocked-for-these-indian-users-reports/articleshow/96687992.cms>
- Windows Security (formerly Defender) and other anti-virus software are known to block the script. The script gets flagged due to the fact that it requires administrator privileges & makes drastic system changes.
- If you are having TLS 1.2 issues, or are having trouble resolving `christitus.com/win` then run with the following command:
```
[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;iex(New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/ChrisTitusTech/winutil/main/winutil.ps1')
```
If you are still having issues try changing your DNS provider to 1.1.1.1 || 1.0.0.1 or 8.8.8.8 || 8.8.4.4
## Support
- To morally and mentally support the project, make sure to leave a ⭐️!

View File

@ -13,16 +13,20 @@ function Install-WinUtilChoco {
if((Test-WinUtilPackageManager -choco) -eq "installed") {
return
}
$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
$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
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
}
}

View File

@ -80,6 +80,7 @@ function Install-WinUtilProgramChoco {
}
}
$x++
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value $using:x/$using:count })
}
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed

View File

@ -97,6 +97,7 @@ Function Install-WinUtilProgramWinget {
}
}
$X++
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value $using:x/$using:count })
}
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
return $failedPackages;

View File

@ -19,6 +19,8 @@ function Install-WinUtilWinget {
Write-Host "`nWinget is not Installed. Continuing with install.`r" -ForegroundColor Red
}
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" })
# Gets the computer's information
if ($null -eq $sync.ComputerInfo){
$ComputerInfo = Get-ComputerInfo -ErrorAction Stop
@ -63,4 +65,6 @@ function Install-WinUtilWinget {
throw [WingetFailedInstall]::new('Failed to install!')
}
}
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" })
}

View File

@ -10,6 +10,8 @@ function Invoke-WinUtilFeatureInstall {
$CheckBox
)
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 1/$using:CheckBox.Count })
$CheckBox | ForEach-Object {
if($sync.configs.feature.$psitem.feature){
Foreach( $feature in $sync.configs.feature.$psitem.feature ){
@ -23,6 +25,7 @@ function Invoke-WinUtilFeatureInstall {
}
else{
Set-WinUtilTaskbaritem -state "Error"
Write-Warning "Unable to Install $feature due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
@ -36,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*"){
@ -43,6 +47,7 @@ function Invoke-WinUtilFeatureInstall {
}
else{
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
Write-Warning "Unable to Install $feature due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}

View File

@ -0,0 +1,67 @@
<#
.SYNOPSIS
Modifies the Taskbaritem of the WPF Form
.PARAMETER state & value
Value can be between 0 and 1, 0 being no progress done yet and 1 being fully completed
State can be 'None' > No progress, 'Indeterminate' > Without value, 'Normal' > when using value, 'Error' > Red (when using value), 'Paused' > Yellow (when using value)
.PARAMETER overlay
Overlay icon to display on the taskbar item
.EXAMPLE
Set-WinUtilTaskbaritem -value 0.5 -state "Normal"
Set-WinUtilTaskbaritem -state "Error"
Set-WinUtilTaskbaritem -state "Indeterminate"
Set-WinUtilTaskbaritem -description "This is a description"
Set-WinUtilTaskbaritem -overlay "C:\path\to\icon.png"
#>
function Set-WinUtilTaskbaritem {
param (
[double]$value,
$state,
$overlay,
$description
)
if ($value) {
$sync["Form"].taskbarItemInfo.ProgressValue = $value
}
if ($state) {
$sync["Form"].taskbarItemInfo.ProgressState = $state
}
if ($overlay -and (Test-Path $overlay)) {
# Read the image file as a byte array
$imageBytes = [System.IO.File]::ReadAllBytes($overlay)
# Convert the byte array to a Base64 string
[System.Convert]::ToBase64String($imageBytes)
# Load the image file as a bitmap
$bitmap = [System.Drawing.Bitmap]::new($overlay)
# Create a streaming image by streaming the bitmap to a memory stream
$memoryStream = [System.IO.MemoryStream]::new()
$bitmap.Save($memoryStream, [System.Drawing.Imaging.ImageFormat]::Png)
$memoryStream.Position = 0
# Create a bitmap image from the memory stream
$bitmapImage = [System.Windows.Media.Imaging.BitmapImage]::new()
$bitmapImage.BeginInit()
$bitmapImage.StreamSource = $memoryStream
$bitmapImage.EndInit()
$bitmapImage.Freeze()
$sync["Form"].taskbarItemInfo.Overlay = $bitmapImage
}
if ($description) {
$sync["Form"].taskbarItemInfo.Description = $description
}
}

View File

@ -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" })
}
}

View File

@ -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"
# 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"
@ -239,6 +242,7 @@ function Invoke-WPFGetIso {
$sync.BusyMessage.Visibility="Hidden"
$sync.ProcessRunning = $false
Set-WinUtilTaskbaritem -state "None"
}

View File

@ -20,8 +20,10 @@ function Invoke-WPFInstall {
return
}
Invoke-WPFRunspace -ArgumentList $PackagesToInstall -DebugPreference $DebugPreference -ScriptBlock {
param($PackagesToInstall, $DebugPreference)
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 1/$using:PackagesToInstall.Count })
$packagesWinget, $packagesChoco = {
$packagesWinget = [System.Collections.Generic.List`1[System.Object]]::new()
$packagesChoco = [System.Collections.Generic.List`1[System.Object]]::new()
@ -52,11 +54,13 @@ function Invoke-WPFInstall {
Write-Host "==========================================="
Write-Host "-- Installs have finished ---"
Write-Host "==========================================="
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" })
}
Catch {
Write-Host "==========================================="
Write-Host "Error: $_"
Write-Host "==========================================="
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
}
Start-Sleep -Seconds 5
$sync.ProcessRunning = $False

View File

@ -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)
@ -42,6 +43,8 @@ public class PowerManagement {
return
}
Set-WinUtilTaskbaritem -state "Indeterminate"
Write-Host "Target ISO location: $($SaveDialog.FileName)"
$index = $sync.MicrowinWindowsFlavors.SelectedValue.Split(":")[0].Trim()
@ -477,5 +480,6 @@ public class PowerManagement {
# Allow the machine to sleep again (optional)
[PowerManagement]::SetThreadExecutionState(0)
$sync.ProcessRunning = $false
Set-WinUtilTaskbaritem -state "None"
}
}

View File

@ -29,8 +29,10 @@ function Invoke-WPFUnInstall {
if($confirm -eq "No"){return}
Invoke-WPFRunspace -ArgumentList $PackagesToInstall -DebugPreference $DebugPreference -ScriptBlock {
param($PackagesToInstall, $DebugPreference)
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 1/$using:PackagesToInstall.Count })
$packagesWinget, $packagesChoco = {
$packagesWinget = [System.Collections.Generic.List`1[System.Object]]::new()
$packagesChoco = [System.Collections.Generic.List`1[System.Object]]::new()
@ -66,11 +68,13 @@ function Invoke-WPFUnInstall {
Write-Host "==========================================="
Write-Host "-- Uninstalls have finished ---"
Write-Host "==========================================="
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" })
}
Catch {
Write-Host "==========================================="
Write-Host "Error: $_"
Write-Host "==========================================="
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
}
$sync.ProcessRunning = $False
}

View File

@ -30,15 +30,18 @@ function Invoke-WPFtweaksbutton {
$sync.ProcessRunning = $true
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 1/$Tweaks.Count })
$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 ($using:cnt/$using:Tweaks.Count)})
}
$sync.ProcessRunning = $false
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" })
Write-Host "================================="
Write-Host "-- Tweaks are Finished ---"
Write-Host "================================="

View File

@ -24,12 +24,14 @@ function Invoke-WPFundoall {
param($Tweaks, $DebugPreference)
$sync.ProcessRunning = $true
# $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value $using:Tweaks.Count })
Foreach ($tweak in $tweaks){
Invoke-WinUtilTweaks $tweak -undo $true
}
$sync.ProcessRunning = $false
$sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" })
Write-Host "=================================="
Write-Host "--- Undo Tweaks are Finished ---"
Write-Host "=================================="

View File

@ -153,6 +153,16 @@ Invoke-WPFRunspace -ScriptBlock {
# Print the logo
Invoke-WPFFormVariables
# download the logo
$logoUrl = "https://christitus.com/images/logo-full.png"
# Download the image
$logoPath = "$env:TEMP\cttlogo.png"
Invoke-WebRequest -Uri $logoUrl -OutFile $logoPath
# Progress bar in taskbaritem > Set-WinUtilProgressbar
$sync["Form"].TaskbarItemInfo = New-Object System.Windows.Shell.TaskbarItemInfo
Set-WinUtilTaskbaritem -state "None"
# Set the titlebar
$sync["Form"].title = $sync["Form"].title + " " + $sync.version
# Set the commands that will run when the form is closed
@ -287,37 +297,8 @@ Add-Type @"
}
}
# Using a TaskbarItem Overlay until someone figures out how to replace the icon correctly
# URL of the image
$imageUrl = "https://christitus.com/images/logo-full.png"
# Download the image
$imagePath = "$env:TEMP\logo-full.png"
Invoke-WebRequest -Uri $imageUrl -OutFile $imagePath
# Read the image file as a byte array
$imageBytes = [System.IO.File]::ReadAllBytes($imagePath)
# Convert the byte array to a Base64 string
$base64String = [System.Convert]::ToBase64String($imageBytes)
# Create a streaming image by streaming the base64 string to a bitmap streamsource
$bitmap = New-Object System.Windows.Media.Imaging.BitmapImage
$bitmap.BeginInit()
$bitmap.StreamSource = [System.IO.MemoryStream][System.Convert]::FromBase64String($base64String)
$bitmap.EndInit()
$bitmap.Freeze()
# Ensure TaskbarItemInfo is created if not already
if (-not $sync["Form"].TaskbarItemInfo) {
$sync["Form"].TaskbarItemInfo = New-Object System.Windows.Shell.TaskbarItemInfo
}
# Set the overlay icon for the taskbar
$sync["Form"].TaskbarItemInfo.Overlay = $bitmap
Set-WinUtilTaskbaritem -overlay $logoPath
$rect = New-Object RECT
[Window]::GetWindowRect($windowHandle, [ref]$rect)

View File

@ -16,7 +16,7 @@
function Get-LatestRelease {
try {
$releases = Invoke-RestMethod -Uri 'https://api.github.com/repos/ChrisTitusTech/winutil/releases'
$latestRelease = $releases | Select-Object -First 1
$latestRelease = $releases | Where-Object {$_.prerelease -eq $true} | Select-Object -First 1
return $latestRelease.tag_name
} catch {
Write-Host "Error fetching release data: $_" -ForegroundColor Red

12123
winutil.ps1

File diff suppressed because it is too large Load Diff