From 2839500448649fe7065e7fe07cb4a5be24ec7d40 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Mon, 9 Jan 2023 01:25:39 +0100 Subject: [PATCH] Run App in Mods Template/Functions too --- Winget-AutoUpdate/mods/_AppID-template.ps1 | 8 ++++++++ Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Winget-AutoUpdate/mods/_AppID-template.ps1 index e824b73..5ceac13 100644 --- a/Winget-AutoUpdate/mods/_AppID-template.ps1 +++ b/Winget-AutoUpdate/mods/_AppID-template.ps1 @@ -1,4 +1,9 @@ <# ARRAYS/VARIABLES #> +#App to Run ($RunWait = $False if it shouldn't be waited for) +$Run = "" +$RunSwitch = "" +$RunWait = $True + #Beginning of Process Name to Stop - optional wildcard (*) after, without .exe, multiple: "proc1","proc2" $Proc = @("") @@ -43,6 +48,9 @@ $CopyTo = "" . $PSScriptRoot\_Mods-Functions.ps1 <# MAIN #> +if ($Run) { + Invoke-ModsApp $Run $RunSwitch $RunWait +} if ($Proc) { Stop-ModsProc $Proc } diff --git a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index e57e53a..705d344 100644 --- a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -1,5 +1,18 @@ #Common shared functions for mods handling +function Invoke-ModsApp ($Run, $RunSwitch, $RunWait) { + if (Test-Path "$Run") { + if (!$RunWait) { + Start-Process $Run -ArgumentList $RunSwitch + } + else { + Start-Process $Run -ArgumentList $RunSwitch -Wait + } + } + Return +} + + function Stop-ModsProc ($Proc) { foreach ($process in $Proc) { @@ -7,6 +20,7 @@ function Stop-ModsProc ($Proc) { } Return } + function Wait-ModsProc ($Wait) { foreach ($process in $Wait) { @@ -14,6 +28,7 @@ function Wait-ModsProc ($Wait) { } Return } + function Uninstall-ModsApp ($App) { foreach ($app in $App) { @@ -131,6 +146,7 @@ function Uninstall-ModsApp ($App) { } Return } + function Remove-ModsLnk ($Lnk) { foreach ($link in $Lnk) {