From 932760cbdf7bd35e7d5e0f119c14757409a275fd Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 12 Apr 2025 17:50:03 +0200 Subject: [PATCH 01/17] Counter in Remove-ModsLnk --- Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 01955c7d..637a8049 100644 --- a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -141,10 +141,15 @@ Function Process-installedSoftware() { } function Remove-ModsLnk ($Lnk) { + $removedCount = 0 foreach ($link in $Lnk) { - Remove-Item -Path "${env:Public}\Desktop\$link.lnk" -Force -ErrorAction SilentlyContinue | Out-Null + $linkPath = "${env:Public}\Desktop\$link.lnk" + if (Test-Path $linkPath) { + Remove-Item -Path $linkPath -Force -ErrorAction SilentlyContinue | Out-Null + $removedCount++ + } } - Return + Return $removedCount } function Add-ModsReg ($AddKey, $AddValue, $AddTypeData, $AddType) { From dc219081ae8581bdc61b2a69432606b5728be812 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 12 Apr 2025 17:58:02 +0200 Subject: [PATCH 02/17] Approved Verbs --- Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 637a8049..3fab2a7c 100644 --- a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -56,17 +56,17 @@ function Uninstall-WingetID ($WingetIDUninst) { function Uninstall-ModsApp ($AppUninst, $AllVersions) { foreach ($app in $AppUninst) { # we start from scanning the x64 node in registry, if something was found, then we set x64=TRUE - [bool]$app_was_x64 = Process-installedSoftware -app $app -x64 $true; + [bool]$app_was_x64 = Get-InstalledSoftware -app $app -x64 $true; # if nothing was found in x64 node, then we repeat that action in x86 node if (!$app_was_x64) { - Process-installedSoftware -app $app | Out-Null; + Get-InstalledSoftware -app $app | Out-Null; } } Return } -Function Process-installedSoftware() { +Function Get-InstalledSoftware() { [OutputType([Bool])] Param( [parameter(Mandatory = $true)] [string]$app, From d22f3957e195f28ffc27dbed9197a90823e21b05 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 12 Apr 2025 19:38:14 +0200 Subject: [PATCH 03/17] Added functions and examples in _WAU-mods-postsys-template --- .../mods/_WAU-mods-postsys-template.ps1 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 b/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 index df9dcd1d..3cd3b2da 100644 --- a/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 @@ -6,11 +6,20 @@ Make sure your Functions have unique names! #> <# FUNCTIONS #> - +. $PSScriptRoot\_Mods-Functions.ps1 <# ARRAYS/VARIABLES #> +#Example: +#Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1","lnk2" +#The function Remove-ModsLnk returns the number of removed links. +#$Lnk = @("Acrobat Read*","Bitwarden","calibre*") <# MAIN #> +#Example: +# if ($Lnk) { +# $removedCount = Remove-ModsLnk $Lnk +# Write-ToLog "-> Removed $($removedCount) Public Desktop Links!" "Green" +# } Write-ToLog "...nothing to do!" "Green" From 02806ad9fafd31ce3790b28f33e04de9932cb047 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 12 Apr 2025 19:41:03 +0200 Subject: [PATCH 04/17] Added better log output for Mods (postsys) for WAU --- Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 b/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 index 3cd3b2da..ad1be36e 100644 --- a/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 @@ -22,4 +22,4 @@ Make sure your Functions have unique names! # Write-ToLog "-> Removed $($removedCount) Public Desktop Links!" "Green" # } -Write-ToLog "...nothing to do!" "Green" +Write-ToLog "-> ...Mods (postsys) for WAU has nothing more to do!" "Green" From fc3ab19d067d0c6e46b6fd614d011f8637562023 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sat, 12 Apr 2025 19:46:45 +0200 Subject: [PATCH 05/17] Line comment spaces --- .../mods/_WAU-mods-postsys-template.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 b/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 index ad1be36e..4455228a 100644 --- a/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 @@ -9,14 +9,14 @@ Make sure your Functions have unique names! . $PSScriptRoot\_Mods-Functions.ps1 <# ARRAYS/VARIABLES #> -#Example: -#Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1","lnk2" -#The function Remove-ModsLnk returns the number of removed links. -#$Lnk = @("Acrobat Read*","Bitwarden","calibre*") +# Example: +# Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1","lnk2" +# The function Remove-ModsLnk returns the number of removed links. +# $Lnk = @("Acrobat Read*","Bitwarden","calibre*") <# MAIN #> -#Example: +# Example: # if ($Lnk) { # $removedCount = Remove-ModsLnk $Lnk # Write-ToLog "-> Removed $($removedCount) Public Desktop Links!" "Green" From f594401cece538c1ca59780adbcc715a8c494199 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 13 Apr 2025 06:30:09 +0200 Subject: [PATCH 06/17] Template changes --- .../mods/_AppID-template.ps1 | 16 +++++++++-- .../mods/_WAU-mods-postsys-template.ps1 | 1 + .../mods/_WAU-mods-template.ps1 | 1 + .../mods/_WAU-notinstalled-template.ps1 | 28 ++++++++++--------- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1 index b7fa5f2f..8318ed3c 100644 --- a/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1 @@ -1,3 +1,16 @@ +<# A mods template for apps +Possible use cases: +"$Mods\AppID-preinstall.ps1" +"$Mods\AppID-install.ps1" +"$Mods\AppID-upgrade.ps1" +"$Mods\AppID-installed.ps1" +"$Mods\AppID-notinstalled.ps1" +#> + +<# FUNCTIONS #> +. $PSScriptRoot\_Mods-Functions.ps1 + + <# ARRAYS/VARIABLES #> #App to Run (as SYSTEM) #$RunWait = $False if it shouldn't be waited for completion. Example: @@ -82,8 +95,6 @@ $GrantPath = @("") $RunUser = "" $User = $True -<# FUNCTIONS #> -. $PSScriptRoot\_Mods-Functions.ps1 <# MAIN #> if ($RunSystem) { @@ -135,4 +146,5 @@ if ($RunUser) { Invoke-ModsApp $RunUser "" "" $User } + <# EXTRAS #> diff --git a/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 b/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 index 4455228a..b2668970 100644 --- a/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1 @@ -8,6 +8,7 @@ Make sure your Functions have unique names! <# FUNCTIONS #> . $PSScriptRoot\_Mods-Functions.ps1 + <# ARRAYS/VARIABLES #> # Example: # Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1","lnk2" diff --git a/Sources/Winget-AutoUpdate/mods/_WAU-mods-template.ps1 b/Sources/Winget-AutoUpdate/mods/_WAU-mods-template.ps1 index 5de6d0d4..c85e6707 100644 --- a/Sources/Winget-AutoUpdate/mods/_WAU-mods-template.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_WAU-mods-template.ps1 @@ -7,6 +7,7 @@ Exit 1 to Re-run WAU from this script (beware of loops)! #> <# FUNCTIONS #> +. $PSScriptRoot\_Mods-Functions.ps1 <# ARRAYS/VARIABLES #> diff --git a/Sources/Winget-AutoUpdate/mods/_WAU-notinstalled-template.ps1 b/Sources/Winget-AutoUpdate/mods/_WAU-notinstalled-template.ps1 index 9f552299..4812121d 100644 --- a/Sources/Winget-AutoUpdate/mods/_WAU-notinstalled-template.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_WAU-notinstalled-template.ps1 @@ -10,20 +10,22 @@ This all-purpose mod will be overridden by any specific: <# FUNCTIONS #> . $PSScriptRoot\_Mods-Functions.ps1 + <# ARRAYS/VARIABLES #> <# MAIN #> -if ($($app.Id) -eq "Microsoft.SQLServerManagementStudio") { - if ($ConfirmInstall -eq $false) { - try { - Write-ToLog "...successfully done something" "Green" - } - catch { - Write-ToLog "...failed to do something" "Red" - } - } -} -else { - Write-ToLog "...nothing defined for $($app.Id)" "Yellow" -} +# Example: +# if ($($app.Id) -eq "Microsoft.SQLServerManagementStudio") { +# if ($ConfirmInstall -eq $false) { +# try { +# Write-ToLog "...successfully done something" "Green" +# } +# catch { +# Write-ToLog "...failed to do something" "Red" +# } +# } +# } +# else { +# Write-ToLog "...nothing defined for $($app.Id)" "Yellow" +# } From 3fb5c2833821ce4ecca22b8a072143e821a31cd7 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 16 Apr 2025 23:18:23 +0200 Subject: [PATCH 07/17] Improved detection logic --- .../mods/_Mods-Functions.ps1 | 61 +++++++++++++------ 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 3fab2a7c..73e6417d 100644 --- a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -88,9 +88,9 @@ Function Get-InstalledSoftware() { if ($UninstallString -like "MsiExec.exe*") { $ProductCode = Select-String "{.*}" -inputobject $UninstallString $ProductCode = $ProductCode.matches.groups[0].value - #MSI x64 Installer + # MSI Installer $Exec = Start-Process "C:\Windows\System32\msiexec.exe" -ArgumentList "/x$ProductCode REBOOT=R /qn" -PassThru -Wait - #Stop Hard Reboot (if bad MSI!) + # Stop Hard Reboot (if bad MSI!) if ($Exec.ExitCode -eq 1641) { Start-Process "C:\Windows\System32\shutdown.exe" -ArgumentList "/a" } @@ -101,31 +101,52 @@ Function Get-InstalledSoftware() { $QuietUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $QuietUninstallString $Command = $QuietUninstallString.matches.groups[1].value $Parameter = $QuietUninstallString.matches.groups[2].value - #All EXE x64 Installers (already defined silent uninstall) + # All EXE Installers (already defined silent uninstall) Start-Process $Command -ArgumentList $Parameter -Wait } else { - if ((Test-Path $CleanedUninstallString)) { - $NullSoft = Select-String -Path $CleanedUninstallString -Pattern "Nullsoft" - } - if ($NullSoft) { - #NSIS x64 Installer - Start-Process $UninstallString -ArgumentList "/S" -Wait - } - else { - if ((Test-Path $CleanedUninstallString)) { - $Inno = Select-String -Path $CleanedUninstallString -Pattern "Inno Setup" - } - if ($Inno) { - #Inno x64 Installer - Start-Process $UninstallString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait + # Improved detection logic + if ((Test-Path $CleanedUninstallString -ErrorAction SilentlyContinue)) { + try { + # Read only the first kilobytes to find installer signatures + $fileContent = Get-Content -Path $CleanedUninstallString -TotalCount 4096 -Raw -ErrorAction Stop + + if ($fileContent -match "Nullsoft" -or $fileContent -match "NSIS") { + # NSIS Installer + Start-Process $UninstallString -ArgumentList "/NCRC /S" -Wait + } + elseif ($fileContent -match "Inno Setup") { + # Inno Installer + Start-Process $UninstallString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait + } +<# # Add more installation engines here + elseif ($fileContent -match "InstallShield") { + # InstallShield + Start-Process $UninstallString -ArgumentList "/s" -Wait + } + elseif ($fileContent -match "Wise Installation Wizard") { + # Wise Installer + Start-Process $UninstallString -ArgumentList "/s" -Wait + } + elseif ($fileContent -match "Advanced Installer") { + # Advanced Installer + Start-Process $UninstallString -ArgumentList "/quiet" -Wait + } + #> else { + Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..." + $NativeUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $UninstallString + $Command = $NativeUninstallString.matches.groups[1].value + $Parameter = $NativeUninstallString.matches.groups[2].value + Start-Process $Command -ArgumentList $Parameter -Wait + } } - else { - Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..." + catch { + Write-Warning "Could not read installer file: $_" + # Fallback to standard method + Write-Host "Failed to inspect installer, trying UninstallString directly..." $NativeUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $UninstallString $Command = $NativeUninstallString.matches.groups[1].value $Parameter = $NativeUninstallString.matches.groups[2].value - #All EXE x64 Installers (native defined uninstall) Start-Process $Command -ArgumentList $Parameter -Wait } } From 87bbe204cf4d193cc3f7b6b4b5ab0abdf9676182 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 16 Apr 2025 23:32:20 +0200 Subject: [PATCH 08/17] $env:SystemRoot as Path --- Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 73e6417d..f7abe4e3 100644 --- a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -89,10 +89,10 @@ Function Get-InstalledSoftware() { $ProductCode = Select-String "{.*}" -inputobject $UninstallString $ProductCode = $ProductCode.matches.groups[0].value # MSI Installer - $Exec = Start-Process "C:\Windows\System32\msiexec.exe" -ArgumentList "/x$ProductCode REBOOT=R /qn" -PassThru -Wait + $Exec = Start-Process "$env:SystemRoot\System32\msiexec.exe" -ArgumentList "/x$ProductCode REBOOT=R /qn" -PassThru -Wait # Stop Hard Reboot (if bad MSI!) if ($Exec.ExitCode -eq 1641) { - Start-Process "C:\Windows\System32\shutdown.exe" -ArgumentList "/a" + Start-Process "$env:SystemRoot\System32\shutdown.exe" -ArgumentList "/a" } } else { @@ -119,7 +119,7 @@ Function Get-InstalledSoftware() { # Inno Installer Start-Process $UninstallString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait } -<# # Add more installation engines here +<# # More installation engines goes here elseif ($fileContent -match "InstallShield") { # InstallShield Start-Process $UninstallString -ArgumentList "/s" -Wait From ea2bc812b0e1889916c540d789b60f3c36448538 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 17 Apr 2025 19:25:12 +0200 Subject: [PATCH 09/17] Corrections and better Uninstall name tests in files --- .../mods/_AppID-template.ps1 | 78 +++++++++---------- .../mods/_Mods-Functions.ps1 | 16 ++-- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1 index 8318ed3c..265f87c4 100644 --- a/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1 @@ -12,86 +12,86 @@ Possible use cases: <# ARRAYS/VARIABLES #> -#App to Run (as SYSTEM) -#$RunWait = $False if it shouldn't be waited for completion. Example: -#$RunSystem = "$PSScriptRoot\bins\MsiZap.exe" -#$RunSwitch = "tw! {GUID}" +# App to Run (as SYSTEM) +# $RunWait = $False if it shouldn't be waited for completion. Example: +# $RunSystem = "$PSScriptRoot\bins\MsiZap.exe" +# $RunSwitch = "tw! {GUID}" $RunSystem = "" $RunSwitch = "" $RunWait = $True -#Beginning of Process Name to Stop - optional wildcard (*) after, without .exe, multiple: "proc1","proc2" +# Beginning of Process Name to Stop - optional wildcard (*) after, without .exe, multiple: "proc1*","proc2" $Proc = @("") -#Beginning of Service Name to Stop - multiple: "service1.exe","service2.exe" +# Beginning of Service Name to Stop - - optional wildcard (*) after, multiple: "service1*","service2" $Svc = @("") -#Beginning of Process Name to Wait for to End - optional wildcard (*) after, without .exe, multiple: "proc1","proc2" +# Beginning of Process Name to Wait for to End - optional wildcard (*) after, without .exe, multiple: "proc1*","proc2" $Wait = @("") -#Install App from Winget Repo, multiple: "appID1","appID2". Example: -#$WingetIDInst = @("Microsoft.PowerToys") +# Install App from Winget Repo, multiple: "appID1","appID2". Example: +# $WingetIDInst = @("Microsoft.PowerToys") $WingetIDInst = @("") -#WingetID to uninstall in default manifest mode (silent if supported) -#Multiple: "ID1","ID2". Example: -#$WingetIDUninst = @("Microsoft.PowerToys") +# WingetID to uninstall in default manifest mode (silent if supported) +# Multiple: "ID1","ID2". Example: +# $WingetIDUninst = @("Microsoft.PowerToys") $WingetIDUninst = @("") -#Beginning of App Name string to Silently Uninstall (MSI/NSIS/INNO/EXE with defined silent uninstall in registry) -#Multiple: "app1*","app2*", required wildcard (*) after; search is done with "-like"! -#Uninstall all versions if there exist several? +# The partial beginning (with *) or full display name of App to Silently Uninstall (MSI/NSIS/INNO/EXE with defined silent uninstall in registry) +# Multiple: "app1*","app2" ; search is done with "-like"! +# Uninstall all versions if there exist several? $AppUninst = @("") $AllVersions = $False -#Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1","lnk2" +# Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1*","lnk2" $Lnk = @("") -#Registry _value_ (DWord/String) to add in existing registry Key (Key created if not existing). Example: -#$AddKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -#$AddValue = "WAU_BypassListForUsers" -#$AddTypeData = "1" -#$AddType = "DWord" +# Registry _value_ (DWord/String) to add in existing registry Key (Key created if not existing). Example: +# $AddKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" +# $AddValue = "WAU_BypassListForUsers" +# $AddTypeData = "1" +# $AddType = "DWord" $AddKey = "" $AddValue = "" $AddTypeData = "" $AddType = "" -#Registry _value_ to delete in existing registry Key. -#Value can be omitted for deleting entire Key!. Example: -#$DelKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -#$DelValue = "WAU_BypassListForUsers" +# Registry _value_ to delete in existing registry Key. +# Value can be omitted for deleting entire Key!. Example: +# $DelKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" +# $DelValue = "WAU_BypassListForUsers" $DelKey = "" $DelValue = "" -#Remove file/directory, multiple: "file1","file2" Example: -#$DelFile = @("${env:ProgramFiles}\PowerToys\PowerToys.Update.exe") +# Remove file/directory, multiple: "file1","file2" Example: +# $DelFile = @("${env:ProgramFiles}\PowerToys\PowerToys.Update.exe") $DelFile = @("") -#Rename file/directory. Example: -#$RenFile = "${env:ProgramFiles}\PowerToys\PowerToys.Update.exe" -#$NewName = "PowerToys.Update.org" +# Rename file/directory. Example: +# $RenFile = "${env:ProgramFiles}\PowerToys\PowerToys.Update.exe" +# $NewName = "PowerToys.Update.org" $RenFile = "" $NewName = "" -#Copy file/directory. Example: -#$CopyFile = "C:\Logfiles" -#$CopyTo = "C:\Drawings\Logs" +# Copy file/directory. Example: +# $CopyFile = "C:\Logfiles" +# $CopyTo = "C:\Drawings\Logs" $CopyFile = "" $CopyTo = "" -#Find/Replace text in file. Example: -#$File = "C:\dummy.txt" -#$FindText = 'brown fox' -#$ReplaceText = 'white fox' +# Find/Replace text in file. Example: +# $File = "C:\dummy.txt" +# $FindText = 'brown fox' +# $ReplaceText = 'white fox' $File = "" $FindText = '' $ReplaceText = '' -#Grant "Modify" for directory/file to "Authenticated Users" - multiple: "dir1","dir2" +# Grant "Modify" for directory/file to "Authenticated Users" - multiple: "dir1","dir2" $GrantPath = @("") -#App to Run (as current logged-on user) +# App to Run (as current logged-on user) $RunUser = "" $User = $True diff --git a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index f7abe4e3..43a9614b 100644 --- a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -108,27 +108,27 @@ Function Get-InstalledSoftware() { # Improved detection logic if ((Test-Path $CleanedUninstallString -ErrorAction SilentlyContinue)) { try { - # Read only the first kilobytes to find installer signatures - $fileContent = Get-Content -Path $CleanedUninstallString -TotalCount 4096 -Raw -ErrorAction Stop - - if ($fileContent -match "Nullsoft" -or $fileContent -match "NSIS") { + # Read the whole file to find installer signatures + $fileContent = Get-Content -Path $CleanedUninstallString -Raw -ErrorAction Stop + # Executes silent uninstallation based on installer type + if ($fileContent -match "\bNullsoft\b" -or $fileContent -match "\bNSIS\b") { # NSIS Installer Start-Process $UninstallString -ArgumentList "/NCRC /S" -Wait } - elseif ($fileContent -match "Inno Setup") { + elseif ($fileContent -match "\bInno Setup\b") { # Inno Installer Start-Process $UninstallString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait } <# # More installation engines goes here - elseif ($fileContent -match "InstallShield") { + elseif ($fileContent -match "\bInstallShield\b") { # InstallShield Start-Process $UninstallString -ArgumentList "/s" -Wait } - elseif ($fileContent -match "Wise Installation Wizard") { + elseif ($fileContent -match "\bWise Installation Wizard\b") { # Wise Installer Start-Process $UninstallString -ArgumentList "/s" -Wait } - elseif ($fileContent -match "Advanced Installer") { + elseif ($fileContent -match "\bAdvanced Installer\b") { # Advanced Installer Start-Process $UninstallString -ArgumentList "/quiet" -Wait } From 6e1873cb90f4835ca635e501ebb462d42f85ee21 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Fri, 18 Apr 2025 00:26:06 +0200 Subject: [PATCH 10/17] Fix Nightly build creation after stable release --- .github/workflows/GitFlow_Nightly-builds.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/GitFlow_Nightly-builds.yml b/.github/workflows/GitFlow_Nightly-builds.yml index 9ff90f8a..c919ad26 100644 --- a/.github/workflows/GitFlow_Nightly-builds.yml +++ b/.github/workflows/GitFlow_Nightly-builds.yml @@ -18,11 +18,11 @@ jobs: build: name: Create Nightly Build runs-on: windows-latest - + env: # Define the branch as a variable BRANCH: develop - + steps: # Step 1: Checkout the develop branch for nightly builds - name: Checkout code @@ -39,7 +39,7 @@ jobs: shell: powershell run: | # Find the latest tag of any type - $LATEST_TAG = git tag --sort=-v:refname | Select-Object -First 1 + $LATEST_TAG = git for-each-ref --sort=-creatordate --format '%(refname:short)' refs/tags | Select-Object -First 1 Write-Host "Latest tag: $LATEST_TAG" # Get merged PRs since last tag using Git directly From f0c4448ba37c41c9bdbb1677a90523f91db5c8b1 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 18 Apr 2025 20:35:00 +0200 Subject: [PATCH 11/17] Wise Solutions --- .../mods/_Mods-Functions.ps1 | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 43a9614b..1779c504 100644 --- a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -84,7 +84,8 @@ Function Get-InstalledSoftware() { foreach ($obj in $InstalledSoftware) { if ($obj.GetValue('DisplayName') -like $App) { $UninstallString = $obj.GetValue('UninstallString') - $CleanedUninstallString = $UninstallString.Trim([char]0x0022) + $CleanedUninstallString = $UninstallString.Replace('"', '') + $ExeString = $CleanedUninstallString.Substring(0, $CleanedUninstallString.IndexOf('.exe') + 4) if ($UninstallString -like "MsiExec.exe*") { $ProductCode = Select-String "{.*}" -inputobject $UninstallString $ProductCode = $ProductCode.matches.groups[0].value @@ -98,7 +99,7 @@ Function Get-InstalledSoftware() { else { $QuietUninstallString = $obj.GetValue('QuietUninstallString') if ($QuietUninstallString) { - $QuietUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $QuietUninstallString + $QuietUninstallString = Select-String '("[^"]*") +(.*)' -inputobject $QuietUninstallString $Command = $QuietUninstallString.matches.groups[1].value $Parameter = $QuietUninstallString.matches.groups[2].value # All EXE Installers (already defined silent uninstall) @@ -106,34 +107,40 @@ Function Get-InstalledSoftware() { } else { # Improved detection logic - if ((Test-Path $CleanedUninstallString -ErrorAction SilentlyContinue)) { + if ((Test-Path $ExeString -ErrorAction SilentlyContinue)) { try { # Read the whole file to find installer signatures - $fileContent = Get-Content -Path $CleanedUninstallString -Raw -ErrorAction Stop + $fileContent = Get-Content -Path $ExeString -Raw -ErrorAction Stop # Executes silent uninstallation based on installer type if ($fileContent -match "\bNullsoft\b" -or $fileContent -match "\bNSIS\b") { - # NSIS Installer - Start-Process $UninstallString -ArgumentList "/NCRC /S" -Wait + # Nullsoft (NSIS) Installer + Start-Process $ExeString -ArgumentList "/NCRC /S" -Wait } elseif ($fileContent -match "\bInno Setup\b") { # Inno Installer - Start-Process $UninstallString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait + Start-Process $ExeString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait } -<# # More installation engines goes here - elseif ($fileContent -match "\bInstallShield\b") { - # InstallShield - Start-Process $UninstallString -ArgumentList "/s" -Wait + elseif ($fileContent -match "\bWise Solutions\b") { + # Wise Uninstaller (Unwise32.exe) + # Copy files to temp folder so that Unwise32.exe can find Install.log (very, very old system) + $ArgString = $CleanedUninstallString.Substring($UninstallString.IndexOf('.exe') + 4).Trim() + Copy-Item -Path $ExeString -Destination $env:TEMP -Force + $ExeString = Join-Path $env:TEMP (Split-Path $ExeString -Leaf) + Copy-Item -Path $ArgString -Destination $env:TEMP -Force + $ArgString = Join-Path $env:TEMP (Split-Path $ArgString -Leaf) + Start-Process $ExeString -ArgumentList "/s $ArgString" -Wait } - elseif ($fileContent -match "\bWise Installation Wizard\b") { - # Wise Installer - Start-Process $UninstallString -ArgumentList "/s" -Wait - } - elseif ($fileContent -match "\bAdvanced Installer\b") { - # Advanced Installer - Start-Process $UninstallString -ArgumentList "/quiet" -Wait - } - #> else { - Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..." + # More installation engines goes here + # elseif ($fileContent -match "\bInstallShield\b") { + # # InstallShield + # Start-Process $UninstallString -ArgumentList "/s" -Wait + # } + # elseif ($fileContent -match "\bAdvanced Installer\b") { + # # Advanced Installer + # Start-Process $UninstallString -ArgumentList "/quiet" -Wait + # } + else { + Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..." $NativeUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $UninstallString $Command = $NativeUninstallString.matches.groups[1].value $Parameter = $NativeUninstallString.matches.groups[2].value From ab066fcecfd2a3e1f1e0a5a5adb59930e174f5d5 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 18 Apr 2025 21:03:09 +0200 Subject: [PATCH 12/17] Space --- Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 1779c504..648c5f0c 100644 --- a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -130,17 +130,8 @@ Function Get-InstalledSoftware() { $ArgString = Join-Path $env:TEMP (Split-Path $ArgString -Leaf) Start-Process $ExeString -ArgumentList "/s $ArgString" -Wait } - # More installation engines goes here - # elseif ($fileContent -match "\bInstallShield\b") { - # # InstallShield - # Start-Process $UninstallString -ArgumentList "/s" -Wait - # } - # elseif ($fileContent -match "\bAdvanced Installer\b") { - # # Advanced Installer - # Start-Process $UninstallString -ArgumentList "/quiet" -Wait - # } - else { - Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..." + else { + Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..." $NativeUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $UninstallString $Command = $NativeUninstallString.matches.groups[1].value $Parameter = $NativeUninstallString.matches.groups[2].value From 94398032bbb61a6a4e7f90c9bbf546d1782eed2f Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 18 Apr 2025 23:47:28 +0200 Subject: [PATCH 13/17] Comment, clean and remove --- Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 648c5f0c..430b2775 100644 --- a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -113,22 +113,26 @@ Function Get-InstalledSoftware() { $fileContent = Get-Content -Path $ExeString -Raw -ErrorAction Stop # Executes silent uninstallation based on installer type if ($fileContent -match "\bNullsoft\b" -or $fileContent -match "\bNSIS\b") { - # Nullsoft (NSIS) Installer + # Nullsoft (NSIS) Uninstaller Start-Process $ExeString -ArgumentList "/NCRC /S" -Wait } elseif ($fileContent -match "\bInno Setup\b") { - # Inno Installer + # Inno Uninstaller Start-Process $ExeString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait } elseif ($fileContent -match "\bWise Solutions\b") { # Wise Uninstaller (Unwise32.exe) + # Find the Install.log path parameter in the UninstallString + $ArgString = $CleanedUninstallString.Substring($CleanedUninstallString.IndexOf('.exe') + 4).Trim() # Copy files to temp folder so that Unwise32.exe can find Install.log (very, very old system) - $ArgString = $CleanedUninstallString.Substring($UninstallString.IndexOf('.exe') + 4).Trim() Copy-Item -Path $ExeString -Destination $env:TEMP -Force $ExeString = Join-Path $env:TEMP (Split-Path $ExeString -Leaf) Copy-Item -Path $ArgString -Destination $env:TEMP -Force $ArgString = Join-Path $env:TEMP (Split-Path $ArgString -Leaf) + # Execute the uninstaller with the copied Unwise32.exe Start-Process $ExeString -ArgumentList "/s $ArgString" -Wait + # Remove the copied Unwise32.exe from temp folder (Install.log gets deleted by Unwise32.exe) + Remove-Item -Path $ExeString -Force -ErrorAction SilentlyContinue } else { Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..." From f28229987842d0f6eff4833f1e58e813e9a2c07a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 07:41:37 +0000 Subject: [PATCH 14/17] Bump stefanzweifel/git-auto-commit-action from 5.1.0 to 5.2.0 Bumps [stefanzweifel/git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) from 5.1.0 to 5.2.0. - [Release notes](https://github.com/stefanzweifel/git-auto-commit-action/releases) - [Changelog](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/CHANGELOG.md) - [Commits](https://github.com/stefanzweifel/git-auto-commit-action/compare/e348103e9026cc0eee72ae06630dbe30c8bf7a79...b863ae1933cb653a53c021fe36dbb774e1fb9403) --- updated-dependencies: - dependency-name: stefanzweifel/git-auto-commit-action dependency-version: 5.2.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/GA_Mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/GA_Mega-linter.yml b/.github/workflows/GA_Mega-linter.yml index f4c80120..ad272e8a 100644 --- a/.github/workflows/GA_Mega-linter.yml +++ b/.github/workflows/GA_Mega-linter.yml @@ -90,7 +90,7 @@ jobs: run: sudo chown -Rc $UID .git/ - name: Commit and push applied linter fixes if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - uses: stefanzweifel/git-auto-commit-action@e348103e9026cc0eee72ae06630dbe30c8bf7a79 # v5.1.0 + uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0 with: branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} commit_message: "[MegaLinter] Apply linters fixes" From de5afcf3fa4307c48c7504280df73f940ad641ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 06:38:32 +0000 Subject: [PATCH 15/17] Bump oxsecurity/megalinter from 8.5.0 to 8.7.0 Bumps [oxsecurity/megalinter](https://github.com/oxsecurity/megalinter) from 8.5.0 to 8.7.0. - [Release notes](https://github.com/oxsecurity/megalinter/releases) - [Changelog](https://github.com/oxsecurity/megalinter/blob/main/CHANGELOG.md) - [Commits](https://github.com/oxsecurity/megalinter/compare/146333030da68e2e58c6ff826633824fabe01eaf...5a91fb06c83d0e69fbd23756d47438aa723b4a5a) --- updated-dependencies: - dependency-name: oxsecurity/megalinter dependency-version: 8.7.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/GA_Mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/GA_Mega-linter.yml b/.github/workflows/GA_Mega-linter.yml index f4c80120..409fc1b6 100644 --- a/.github/workflows/GA_Mega-linter.yml +++ b/.github/workflows/GA_Mega-linter.yml @@ -43,7 +43,7 @@ jobs: id: ml # You can override MegaLinter flavor used to have faster performances # More info at https://megalinter.github.io/flavors/ - uses: oxsecurity/megalinter@146333030da68e2e58c6ff826633824fabe01eaf # v8.5.0 + uses: oxsecurity/megalinter@5a91fb06c83d0e69fbd23756d47438aa723b4a5a # v8.7.0 env: # All available variables are described in documentation # https://megalinter.github.io/configuration/ From e440198346ffdc8afc6a7c254a3ad10033aab03f Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Mon, 12 May 2025 15:47:36 +0200 Subject: [PATCH 16/17] PAT --- .github/workflows/GA_Mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/GA_Mega-linter.yml b/.github/workflows/GA_Mega-linter.yml index 52393e90..c42200bc 100644 --- a/.github/workflows/GA_Mega-linter.yml +++ b/.github/workflows/GA_Mega-linter.yml @@ -48,7 +48,7 @@ jobs: # All available variables are described in documentation # https://megalinter.github.io/configuration/ VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} SPELL_CSPELL_CONFIG_FILE: .github/cspell.json POWERSHELL_POWERSHELL_CONFIG_FILE: .github/.powershell-psscriptanalyzer.psd1 DISABLE_ERRORS_LINTERS: REPOSITORY_DEVSKIM,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,SPELL_CSPELL,SPELL_PROSELINT,COPYPASTE_JSCPD,MARKDOWN_MARKDOWN_LINK_CHECK From a172c17b596426b579b1bb31ffdd09104d02f7f4 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Mon, 12 May 2025 15:55:47 +0200 Subject: [PATCH 17/17] Update GA_Mega-linter.yml --- .github/workflows/GA_Mega-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/GA_Mega-linter.yml b/.github/workflows/GA_Mega-linter.yml index c42200bc..42fd86c4 100644 --- a/.github/workflows/GA_Mega-linter.yml +++ b/.github/workflows/GA_Mega-linter.yml @@ -35,7 +35,7 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0 # MegaLinter