Skip to content

Commit ea2bc81

Browse files
committed
Corrections and better Uninstall name tests in files
1 parent 87bbe20 commit ea2bc81

File tree

2 files changed

+47
-47
lines changed

2 files changed

+47
-47
lines changed

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

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,86 +12,86 @@ Possible use cases:
1212

1313

1414
<# ARRAYS/VARIABLES #>
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}"
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}"
1919
$RunSystem = ""
2020
$RunSwitch = ""
2121
$RunWait = $True
2222

23-
#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"
2424
$Proc = @("")
2525

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

29-
#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"
3030
$Wait = @("")
3131

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

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

41-
#Beginning of App Name string to Silently Uninstall (MSI/NSIS/INNO/EXE with defined silent uninstall in registry)
42-
#Multiple: "app1*","app2*", required wildcard (*) after; search is done with "-like"!
43-
#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?
4444
$AppUninst = @("")
4545
$AllVersions = $False
4646

47-
#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"
4848
$Lnk = @("")
4949

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"
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"
5555
$AddKey = ""
5656
$AddValue = ""
5757
$AddTypeData = ""
5858
$AddType = ""
5959

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"
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"
6464
$DelKey = ""
6565
$DelValue = ""
6666

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

71-
#Rename file/directory. Example:
72-
#$RenFile = "${env:ProgramFiles}\PowerToys\PowerToys.Update.exe"
73-
#$NewName = "PowerToys.Update.org"
71+
# Rename file/directory. Example:
72+
# $RenFile = "${env:ProgramFiles}\PowerToys\PowerToys.Update.exe"
73+
# $NewName = "PowerToys.Update.org"
7474
$RenFile = ""
7575
$NewName = ""
7676

77-
#Copy file/directory. Example:
78-
#$CopyFile = "C:\Logfiles"
79-
#$CopyTo = "C:\Drawings\Logs"
77+
# Copy file/directory. Example:
78+
# $CopyFile = "C:\Logfiles"
79+
# $CopyTo = "C:\Drawings\Logs"
8080
$CopyFile = ""
8181
$CopyTo = ""
8282

83-
#Find/Replace text in file. Example:
84-
#$File = "C:\dummy.txt"
85-
#$FindText = 'brown fox'
86-
#$ReplaceText = 'white fox'
83+
# Find/Replace text in file. Example:
84+
# $File = "C:\dummy.txt"
85+
# $FindText = 'brown fox'
86+
# $ReplaceText = 'white fox'
8787
$File = ""
8888
$FindText = ''
8989
$ReplaceText = ''
9090

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

94-
#App to Run (as current logged-on user)
94+
# App to Run (as current logged-on user)
9595
$RunUser = ""
9696
$User = $True
9797

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,27 +108,27 @@ Function Get-InstalledSoftware() {
108108
# Improved detection logic
109109
if ((Test-Path $CleanedUninstallString -ErrorAction SilentlyContinue)) {
110110
try {
111-
# Read only the first kilobytes to find installer signatures
112-
$fileContent = Get-Content -Path $CleanedUninstallString -TotalCount 4096 -Raw -ErrorAction Stop
113-
114-
if ($fileContent -match "Nullsoft" -or $fileContent -match "NSIS") {
111+
# Read the whole file to find installer signatures
112+
$fileContent = Get-Content -Path $CleanedUninstallString -Raw -ErrorAction Stop
113+
# Executes silent uninstallation based on installer type
114+
if ($fileContent -match "\bNullsoft\b" -or $fileContent -match "\bNSIS\b") {
115115
# NSIS Installer
116116
Start-Process $UninstallString -ArgumentList "/NCRC /S" -Wait
117117
}
118-
elseif ($fileContent -match "Inno Setup") {
118+
elseif ($fileContent -match "\bInno Setup\b") {
119119
# Inno Installer
120120
Start-Process $UninstallString -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" -Wait
121121
}
122122
<# # More installation engines goes here
123-
elseif ($fileContent -match "InstallShield") {
123+
elseif ($fileContent -match "\bInstallShield\b") {
124124
# InstallShield
125125
Start-Process $UninstallString -ArgumentList "/s" -Wait
126126
}
127-
elseif ($fileContent -match "Wise Installation Wizard") {
127+
elseif ($fileContent -match "\bWise Installation Wizard\b") {
128128
# Wise Installer
129129
Start-Process $UninstallString -ArgumentList "/s" -Wait
130130
}
131-
elseif ($fileContent -match "Advanced Installer") {
131+
elseif ($fileContent -match "\bAdvanced Installer\b") {
132132
# Advanced Installer
133133
Start-Process $UninstallString -ArgumentList "/quiet" -Wait
134134
}

0 commit comments

Comments
 (0)