-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f5d871
commit 60be27c
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# use with https://github.com/stax76/run-hidden to keep a bunch of background processes running, even when they crash | ||
# can run this from windows task scheduler as periodic task | ||
# run program: set to executable downloaded above | ||
# arguments: | ||
# -ExecutionPolicy Bypass -File "C:\path\to\keep_processes_running.ps1" | ||
|
||
# Define the map of processes and their executable paths | ||
$processes = @{ | ||
"olk" = "C:\Program Files\WindowsApps\Microsoft.OutlookForWindows_1.2024.111.100_x64__8wekyb3d8bbwe\olk.exe" | ||
"msedge" = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" | ||
"ms-teams" = "C:\Program Files\WindowsApps\MSTeams_24004.1307.2669.7070_x64__8wekyb3d8bbwe\ms-teams.exe" | ||
} | ||
|
||
# Loop through each key-value pair in the map | ||
foreach ($processName in $processes.Keys) { | ||
$executablePath = $processes[$processName] | ||
|
||
# Check if the process is running | ||
$isRunning = Get-Process -Name "$processName" -ErrorAction SilentlyContinue | ||
|
||
if (-not $isRunning) { | ||
# If the process is not running, start it from its executable in the background | ||
try { | ||
Start-Process -FilePath "$executablePath" -WindowStyle Hidden | ||
} catch { | ||
Write-Host "failed to start $processName from $executablePath" | ||
} | ||
} | ||
} |