Run App in Mods Template/Functions too

pull/257/head
KnifMelti 2023-01-09 01:25:39 +01:00
parent 237e9c3106
commit 2839500448
2 changed files with 24 additions and 0 deletions

View File

@ -1,4 +1,9 @@
<# ARRAYS/VARIABLES #> <# 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" #Beginning of Process Name to Stop - optional wildcard (*) after, without .exe, multiple: "proc1","proc2"
$Proc = @("") $Proc = @("")
@ -43,6 +48,9 @@ $CopyTo = ""
. $PSScriptRoot\_Mods-Functions.ps1 . $PSScriptRoot\_Mods-Functions.ps1
<# MAIN #> <# MAIN #>
if ($Run) {
Invoke-ModsApp $Run $RunSwitch $RunWait
}
if ($Proc) { if ($Proc) {
Stop-ModsProc $Proc Stop-ModsProc $Proc
} }

View File

@ -1,5 +1,18 @@
#Common shared functions for mods handling #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) { function Stop-ModsProc ($Proc) {
foreach ($process in $Proc) foreach ($process in $Proc)
{ {
@ -7,6 +20,7 @@ function Stop-ModsProc ($Proc) {
} }
Return Return
} }
function Wait-ModsProc ($Wait) { function Wait-ModsProc ($Wait) {
foreach ($process in $Wait) foreach ($process in $Wait)
{ {
@ -14,6 +28,7 @@ function Wait-ModsProc ($Wait) {
} }
Return Return
} }
function Uninstall-ModsApp ($App) { function Uninstall-ModsApp ($App) {
foreach ($app in $App) foreach ($app in $App)
{ {
@ -131,6 +146,7 @@ function Uninstall-ModsApp ($App) {
} }
Return Return
} }
function Remove-ModsLnk ($Lnk) { function Remove-ModsLnk ($Lnk) {
foreach ($link in $Lnk) foreach ($link in $Lnk)
{ {