Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Sources/Winget-AutoUpdate/mods/_AppID-template.ps1
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -82,8 +95,6 @@ $GrantPath = @("")
$RunUser = ""
$User = $True

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

<# MAIN #>
if ($RunSystem) {
Expand Down Expand Up @@ -135,4 +146,5 @@ if ($RunUser) {
Invoke-ModsApp $RunUser "" "" $User
}


<# EXTRAS #>
15 changes: 10 additions & 5 deletions Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 11 additions & 1 deletion Sources/Winget-AutoUpdate/mods/_WAU-mods-postsys-template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ 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"
Write-ToLog "-> ...Mods (postsys) for WAU has nothing more to do!" "Green"
1 change: 1 addition & 0 deletions Sources/Winget-AutoUpdate/mods/_WAU-mods-template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Exit 1 to Re-run WAU from this script (beware of loops)!
#>

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


<# ARRAYS/VARIABLES #>
Expand Down
28 changes: 15 additions & 13 deletions Sources/Winget-AutoUpdate/mods/_WAU-notinstalled-template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
# }
Loading