Skip to content

Commit 3d0562c

Browse files
authored
Merge pull request #936 from Romanitho/release/2.5.0
Release 2.5.0
2 parents 14c79f5 + a172c17 commit 3d0562c

File tree

7 files changed

+143
-90
lines changed

7 files changed

+143
-90
lines changed

.github/workflows/GA_Mega-linter.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ jobs:
3535
- name: Checkout Code
3636
uses: actions/checkout@v4
3737
with:
38-
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
38+
token: ${{ secrets.GITHUB_TOKEN }}
3939
fetch-depth: 0
4040

4141
# MegaLinter
4242
- name: MegaLinter
4343
id: ml
4444
# You can override MegaLinter flavor used to have faster performances
4545
# More info at https://megalinter.github.io/flavors/
46-
uses: oxsecurity/megalinter@146333030da68e2e58c6ff826633824fabe01eaf # v8.5.0
46+
uses: oxsecurity/megalinter@5a91fb06c83d0e69fbd23756d47438aa723b4a5a # v8.7.0
4747
env:
4848
# All available variables are described in documentation
4949
# https://megalinter.github.io/configuration/
@@ -90,7 +90,7 @@ jobs:
9090
run: sudo chown -Rc $UID .git/
9191
- name: Commit and push applied linter fixes
9292
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')
93-
uses: stefanzweifel/git-auto-commit-action@e348103e9026cc0eee72ae06630dbe30c8bf7a79 # v5.1.0
93+
uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0
9494
with:
9595
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
9696
commit_message: "[MegaLinter] Apply linters fixes"

.github/workflows/GitFlow_Nightly-builds.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ jobs:
1818
build:
1919
name: Create Nightly Build
2020
runs-on: windows-latest
21-
21+
2222
env:
2323
# Define the branch as a variable
2424
BRANCH: develop
25-
25+
2626
steps:
2727
# Step 1: Checkout the develop branch for nightly builds
2828
- name: Checkout code
@@ -39,7 +39,7 @@ jobs:
3939
shell: powershell
4040
run: |
4141
# Find the latest tag of any type
42-
$LATEST_TAG = git tag --sort=-v:refname | Select-Object -First 1
42+
$LATEST_TAG = git for-each-ref --sort=-creatordate --format '%(refname:short)' refs/tags | Select-Object -First 1
4343
Write-Host "Latest tag: $LATEST_TAG"
4444
4545
# Get merged PRs since last tag using Git directly

Sources/Winget-AutoUpdate/mods/_AppID-template.ps1

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,100 @@
1+
<# A mods template for apps
2+
Possible use cases:
3+
"$Mods\AppID-preinstall.ps1"
4+
"$Mods\AppID-install.ps1"
5+
"$Mods\AppID-upgrade.ps1"
6+
"$Mods\AppID-installed.ps1"
7+
"$Mods\AppID-notinstalled.ps1"
8+
#>
9+
10+
<# FUNCTIONS #>
11+
. $PSScriptRoot\_Mods-Functions.ps1
12+
13+
114
<# ARRAYS/VARIABLES #>
2-
#App to Run (as SYSTEM)
3-
#$RunWait = $False if it shouldn't be waited for completion. Example:
4-
#$RunSystem = "$PSScriptRoot\bins\MsiZap.exe"
5-
#$RunSwitch = "tw! {GUID}"
15+
# App to Run (as SYSTEM)
16+
# $RunWait = $False if it shouldn't be waited for completion. Example:
17+
# $RunSystem = "$PSScriptRoot\bins\MsiZap.exe"
18+
# $RunSwitch = "tw! {GUID}"
619
$RunSystem = ""
720
$RunSwitch = ""
821
$RunWait = $True
922

10-
#Beginning of Process Name to Stop - optional wildcard (*) after, without .exe, multiple: "proc1","proc2"
23+
# Beginning of Process Name to Stop - optional wildcard (*) after, without .exe, multiple: "proc1*","proc2"
1124
$Proc = @("")
1225

13-
#Beginning of Service Name to Stop - multiple: "service1.exe","service2.exe"
26+
# Beginning of Service Name to Stop - - optional wildcard (*) after, multiple: "service1*","service2"
1427
$Svc = @("")
1528

16-
#Beginning of Process Name to Wait for to End - optional wildcard (*) after, without .exe, multiple: "proc1","proc2"
29+
# Beginning of Process Name to Wait for to End - optional wildcard (*) after, without .exe, multiple: "proc1*","proc2"
1730
$Wait = @("")
1831

19-
#Install App from Winget Repo, multiple: "appID1","appID2". Example:
20-
#$WingetIDInst = @("Microsoft.PowerToys")
32+
# Install App from Winget Repo, multiple: "appID1","appID2". Example:
33+
# $WingetIDInst = @("Microsoft.PowerToys")
2134
$WingetIDInst = @("")
2235

23-
#WingetID to uninstall in default manifest mode (silent if supported)
24-
#Multiple: "ID1","ID2". Example:
25-
#$WingetIDUninst = @("Microsoft.PowerToys")
36+
# WingetID to uninstall in default manifest mode (silent if supported)
37+
# Multiple: "ID1","ID2". Example:
38+
# $WingetIDUninst = @("Microsoft.PowerToys")
2639
$WingetIDUninst = @("")
2740

28-
#Beginning of App Name string to Silently Uninstall (MSI/NSIS/INNO/EXE with defined silent uninstall in registry)
29-
#Multiple: "app1*","app2*", required wildcard (*) after; search is done with "-like"!
30-
#Uninstall all versions if there exist several?
41+
# The partial beginning (with *) or full display name of App to Silently Uninstall (MSI/NSIS/INNO/EXE with defined silent uninstall in registry)
42+
# Multiple: "app1*","app2" ; search is done with "-like"!
43+
# Uninstall all versions if there exist several?
3144
$AppUninst = @("")
3245
$AllVersions = $False
3346

34-
#Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1","lnk2"
47+
# Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1*","lnk2"
3548
$Lnk = @("")
3649

37-
#Registry _value_ (DWord/String) to add in existing registry Key (Key created if not existing). Example:
38-
#$AddKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
39-
#$AddValue = "WAU_BypassListForUsers"
40-
#$AddTypeData = "1"
41-
#$AddType = "DWord"
50+
# Registry _value_ (DWord/String) to add in existing registry Key (Key created if not existing). Example:
51+
# $AddKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
52+
# $AddValue = "WAU_BypassListForUsers"
53+
# $AddTypeData = "1"
54+
# $AddType = "DWord"
4255
$AddKey = ""
4356
$AddValue = ""
4457
$AddTypeData = ""
4558
$AddType = ""
4659

47-
#Registry _value_ to delete in existing registry Key.
48-
#Value can be omitted for deleting entire Key!. Example:
49-
#$DelKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
50-
#$DelValue = "WAU_BypassListForUsers"
60+
# Registry _value_ to delete in existing registry Key.
61+
# Value can be omitted for deleting entire Key!. Example:
62+
# $DelKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
63+
# $DelValue = "WAU_BypassListForUsers"
5164
$DelKey = ""
5265
$DelValue = ""
5366

54-
#Remove file/directory, multiple: "file1","file2" Example:
55-
#$DelFile = @("${env:ProgramFiles}\PowerToys\PowerToys.Update.exe")
67+
# Remove file/directory, multiple: "file1","file2" Example:
68+
# $DelFile = @("${env:ProgramFiles}\PowerToys\PowerToys.Update.exe")
5669
$DelFile = @("")
5770

58-
#Rename file/directory. Example:
59-
#$RenFile = "${env:ProgramFiles}\PowerToys\PowerToys.Update.exe"
60-
#$NewName = "PowerToys.Update.org"
71+
# Rename file/directory. Example:
72+
# $RenFile = "${env:ProgramFiles}\PowerToys\PowerToys.Update.exe"
73+
# $NewName = "PowerToys.Update.org"
6174
$RenFile = ""
6275
$NewName = ""
6376

64-
#Copy file/directory. Example:
65-
#$CopyFile = "C:\Logfiles"
66-
#$CopyTo = "C:\Drawings\Logs"
77+
# Copy file/directory. Example:
78+
# $CopyFile = "C:\Logfiles"
79+
# $CopyTo = "C:\Drawings\Logs"
6780
$CopyFile = ""
6881
$CopyTo = ""
6982

70-
#Find/Replace text in file. Example:
71-
#$File = "C:\dummy.txt"
72-
#$FindText = 'brown fox'
73-
#$ReplaceText = 'white fox'
83+
# Find/Replace text in file. Example:
84+
# $File = "C:\dummy.txt"
85+
# $FindText = 'brown fox'
86+
# $ReplaceText = 'white fox'
7487
$File = ""
7588
$FindText = ''
7689
$ReplaceText = ''
7790

78-
#Grant "Modify" for directory/file to "Authenticated Users" - multiple: "dir1","dir2"
91+
# Grant "Modify" for directory/file to "Authenticated Users" - multiple: "dir1","dir2"
7992
$GrantPath = @("")
8093

81-
#App to Run (as current logged-on user)
94+
# App to Run (as current logged-on user)
8295
$RunUser = ""
8396
$User = $True
8497

85-
<# FUNCTIONS #>
86-
. $PSScriptRoot\_Mods-Functions.ps1
8798

8899
<# MAIN #>
89100
if ($RunSystem) {
@@ -135,4 +146,5 @@ if ($RunUser) {
135146
Invoke-ModsApp $RunUser "" "" $User
136147
}
137148

149+
138150
<# EXTRAS #>

Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ function Uninstall-WingetID ($WingetIDUninst) {
5656
function Uninstall-ModsApp ($AppUninst, $AllVersions) {
5757
foreach ($app in $AppUninst) {
5858
# we start from scanning the x64 node in registry, if something was found, then we set x64=TRUE
59-
[bool]$app_was_x64 = Process-installedSoftware -app $app -x64 $true;
59+
[bool]$app_was_x64 = Get-InstalledSoftware -app $app -x64 $true;
6060

6161
# if nothing was found in x64 node, then we repeat that action in x86 node
6262
if (!$app_was_x64) {
63-
Process-installedSoftware -app $app | Out-Null;
63+
Get-InstalledSoftware -app $app | Out-Null;
6464
}
6565
}
6666
Return
6767
}
6868

69-
Function Process-installedSoftware() {
69+
Function Get-InstalledSoftware() {
7070
[OutputType([Bool])]
7171
Param(
7272
[parameter(Mandatory = $true)] [string]$app,
@@ -84,48 +84,71 @@ Function Process-installedSoftware() {
8484
foreach ($obj in $InstalledSoftware) {
8585
if ($obj.GetValue('DisplayName') -like $App) {
8686
$UninstallString = $obj.GetValue('UninstallString')
87-
$CleanedUninstallString = $UninstallString.Trim([char]0x0022)
87+
$CleanedUninstallString = $UninstallString.Replace('"', '')
88+
$ExeString = $CleanedUninstallString.Substring(0, $CleanedUninstallString.IndexOf('.exe') + 4)
8889
if ($UninstallString -like "MsiExec.exe*") {
8990
$ProductCode = Select-String "{.*}" -inputobject $UninstallString
9091
$ProductCode = $ProductCode.matches.groups[0].value
91-
#MSI x64 Installer
92-
$Exec = Start-Process "C:\Windows\System32\msiexec.exe" -ArgumentList "/x$ProductCode REBOOT=R /qn" -PassThru -Wait
93-
#Stop Hard Reboot (if bad MSI!)
92+
# MSI Installer
93+
$Exec = Start-Process "$env:SystemRoot\System32\msiexec.exe" -ArgumentList "/x$ProductCode REBOOT=R /qn" -PassThru -Wait
94+
# Stop Hard Reboot (if bad MSI!)
9495
if ($Exec.ExitCode -eq 1641) {
95-
Start-Process "C:\Windows\System32\shutdown.exe" -ArgumentList "/a"
96+
Start-Process "$env:SystemRoot\System32\shutdown.exe" -ArgumentList "/a"
9697
}
9798
}
9899
else {
99100
$QuietUninstallString = $obj.GetValue('QuietUninstallString')
100101
if ($QuietUninstallString) {
101-
$QuietUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $QuietUninstallString
102+
$QuietUninstallString = Select-String '("[^"]*") +(.*)' -inputobject $QuietUninstallString
102103
$Command = $QuietUninstallString.matches.groups[1].value
103104
$Parameter = $QuietUninstallString.matches.groups[2].value
104-
#All EXE x64 Installers (already defined silent uninstall)
105+
# All EXE Installers (already defined silent uninstall)
105106
Start-Process $Command -ArgumentList $Parameter -Wait
106107
}
107108
else {
108-
if ((Test-Path $CleanedUninstallString)) {
109-
$NullSoft = Select-String -Path $CleanedUninstallString -Pattern "Nullsoft"
110-
}
111-
if ($NullSoft) {
112-
#NSIS x64 Installer
113-
Start-Process $UninstallString -ArgumentList "/S" -Wait
114-
}
115-
else {
116-
if ((Test-Path $CleanedUninstallString)) {
117-
$Inno = Select-String -Path $CleanedUninstallString -Pattern "Inno Setup"
118-
}
119-
if ($Inno) {
120-
#Inno x64 Installer
121-
Start-Process $UninstallString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait
109+
# Improved detection logic
110+
if ((Test-Path $ExeString -ErrorAction SilentlyContinue)) {
111+
try {
112+
# Read the whole file to find installer signatures
113+
$fileContent = Get-Content -Path $ExeString -Raw -ErrorAction Stop
114+
# Executes silent uninstallation based on installer type
115+
if ($fileContent -match "\bNullsoft\b" -or $fileContent -match "\bNSIS\b") {
116+
# Nullsoft (NSIS) Uninstaller
117+
Start-Process $ExeString -ArgumentList "/NCRC /S" -Wait
118+
}
119+
elseif ($fileContent -match "\bInno Setup\b") {
120+
# Inno Uninstaller
121+
Start-Process $ExeString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait
122+
}
123+
elseif ($fileContent -match "\bWise Solutions\b") {
124+
# Wise Uninstaller (Unwise32.exe)
125+
# Find the Install.log path parameter in the UninstallString
126+
$ArgString = $CleanedUninstallString.Substring($CleanedUninstallString.IndexOf('.exe') + 4).Trim()
127+
# Copy files to temp folder so that Unwise32.exe can find Install.log (very, very old system)
128+
Copy-Item -Path $ExeString -Destination $env:TEMP -Force
129+
$ExeString = Join-Path $env:TEMP (Split-Path $ExeString -Leaf)
130+
Copy-Item -Path $ArgString -Destination $env:TEMP -Force
131+
$ArgString = Join-Path $env:TEMP (Split-Path $ArgString -Leaf)
132+
# Execute the uninstaller with the copied Unwise32.exe
133+
Start-Process $ExeString -ArgumentList "/s $ArgString" -Wait
134+
# Remove the copied Unwise32.exe from temp folder (Install.log gets deleted by Unwise32.exe)
135+
Remove-Item -Path $ExeString -Force -ErrorAction SilentlyContinue
136+
}
137+
else {
138+
Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..."
139+
$NativeUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $UninstallString
140+
$Command = $NativeUninstallString.matches.groups[1].value
141+
$Parameter = $NativeUninstallString.matches.groups[2].value
142+
Start-Process $Command -ArgumentList $Parameter -Wait
143+
}
122144
}
123-
else {
124-
Write-Host "$(if($true -eq $x64) {'x64'} else {'x86'}) Uninstaller unknown, trying the UninstallString from registry..."
145+
catch {
146+
Write-Warning "Could not read installer file: $_"
147+
# Fallback to standard method
148+
Write-Host "Failed to inspect installer, trying UninstallString directly..."
125149
$NativeUninstallString = Select-String "(\x22.*\x22) +(.*)" -inputobject $UninstallString
126150
$Command = $NativeUninstallString.matches.groups[1].value
127151
$Parameter = $NativeUninstallString.matches.groups[2].value
128-
#All EXE x64 Installers (native defined uninstall)
129152
Start-Process $Command -ArgumentList $Parameter -Wait
130153
}
131154
}
@@ -141,10 +164,15 @@ Function Process-installedSoftware() {
141164
}
142165

143166
function Remove-ModsLnk ($Lnk) {
167+
$removedCount = 0
144168
foreach ($link in $Lnk) {
145-
Remove-Item -Path "${env:Public}\Desktop\$link.lnk" -Force -ErrorAction SilentlyContinue | Out-Null
169+
$linkPath = "${env:Public}\Desktop\$link.lnk"
170+
if (Test-Path $linkPath) {
171+
Remove-Item -Path $linkPath -Force -ErrorAction SilentlyContinue | Out-Null
172+
$removedCount++
173+
}
146174
}
147-
Return
175+
Return $removedCount
148176
}
149177

150178
function Add-ModsReg ($AddKey, $AddValue, $AddTypeData, $AddType) {

Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ Make sure your Functions have unique names!
66
#>
77

88
<# FUNCTIONS #>
9+
. $PSScriptRoot\_Mods-Functions.ps1
910

1011

1112
<# ARRAYS/VARIABLES #>
13+
# Example:
14+
# Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1","lnk2"
15+
# The function Remove-ModsLnk returns the number of removed links.
16+
# $Lnk = @("Acrobat Read*","Bitwarden","calibre*")
1217

1318

1419
<# MAIN #>
20+
# Example:
21+
# if ($Lnk) {
22+
# $removedCount = Remove-ModsLnk $Lnk
23+
# Write-ToLog "-> Removed $($removedCount) Public Desktop Links!" "Green"
24+
# }
1525

16-
Write-ToLog "...nothing to do!" "Green"
26+
Write-ToLog "-> ...Mods (postsys) for WAU has nothing more to do!" "Green"

Sources/Winget-AutoUpdate/mods/_WAU-mods-template.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Exit 1 to Re-run WAU from this script (beware of loops)!
77
#>
88

99
<# FUNCTIONS #>
10+
. $PSScriptRoot\_Mods-Functions.ps1
1011

1112

1213
<# ARRAYS/VARIABLES #>

Sources/Winget-AutoUpdate/mods/_WAU-notinstalled-template.ps1

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@ This all-purpose mod will be overridden by any specific:
1010
<# FUNCTIONS #>
1111
. $PSScriptRoot\_Mods-Functions.ps1
1212

13+
1314
<# ARRAYS/VARIABLES #>
1415

1516

1617
<# MAIN #>
17-
if ($($app.Id) -eq "Microsoft.SQLServerManagementStudio") {
18-
if ($ConfirmInstall -eq $false) {
19-
try {
20-
Write-ToLog "...successfully done something" "Green"
21-
}
22-
catch {
23-
Write-ToLog "...failed to do something" "Red"
24-
}
25-
}
26-
}
27-
else {
28-
Write-ToLog "...nothing defined for $($app.Id)" "Yellow"
29-
}
18+
# Example:
19+
# if ($($app.Id) -eq "Microsoft.SQLServerManagementStudio") {
20+
# if ($ConfirmInstall -eq $false) {
21+
# try {
22+
# Write-ToLog "...successfully done something" "Green"
23+
# }
24+
# catch {
25+
# Write-ToLog "...failed to do something" "Red"
26+
# }
27+
# }
28+
# }
29+
# else {
30+
# Write-ToLog "...nothing defined for $($app.Id)" "Yellow"
31+
# }

0 commit comments

Comments
 (0)