Skip to content

Commit 24d9636

Browse files
committed
Mods Template and Function to handle skipping install/upgrade/uninstall
1 parent c6b5ee7 commit 24d9636

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ $RunSystem = ""
2020
$RunSwitch = ""
2121
$RunWait = $True
2222

23+
# Beginning of Process Name to check for if running - optional wildcard (*) after, without .exe, multiple: "proc1*","proc2"
24+
# If found, it will return $False, stop this script and request for the main script to skip the app.
25+
$Skip = @("")
26+
2327
# Beginning of Process Name to Stop - optional wildcard (*) after, without .exe, multiple: "proc1*","proc2"
2428
$Proc = @("")
2529

@@ -100,6 +104,9 @@ $User = $True
100104
if ($RunSystem) {
101105
Invoke-ModsApp $RunSystem $RunSwitch $RunWait ""
102106
}
107+
if ($Skip) {
108+
Skip-ModsProc $Skip
109+
}
103110
if ($Proc) {
104111
Stop-ModsProc $Proc
105112
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,23 @@ function Invoke-ModsApp ($Run, $RunSwitch, $RunWait, $User) {
1818
Return
1919
}
2020

21+
function Skip-ModsProc ($Skip) {
22+
foreach ($process in $Skip) {
23+
$running = Get-Process -Name $process -ErrorAction SilentlyContinue
24+
if ($running) {
25+
Return $false
26+
}
27+
}
28+
Return
29+
}
2130

2231
function Stop-ModsProc ($Proc) {
2332
foreach ($process in $Proc) {
2433
Stop-Process -Name $process -Force -ErrorAction SilentlyContinue | Out-Null
2534
}
2635
Return
2736
}
37+
2838
function Stop-ModsSvc ($Svc) {
2939
foreach ($service in $Svc) {
3040
Stop-Service -Name $service -Force -ErrorAction SilentlyContinue | Out-Null

0 commit comments

Comments
 (0)