From ff28c7e29725757d438c27c00c4d061a77a8f218 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Fri, 12 Nov 2021 12:49:21 +0100 Subject: [PATCH] Add open-obs-studio.ps1 and close-obs-studio.ps1 --- Scripts/close-obs-studio.ps1 | 15 +++++++++++++++ Scripts/open-obs-studio.ps1 | 28 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 Scripts/close-obs-studio.ps1 create mode 100644 Scripts/open-obs-studio.ps1 diff --git a/Scripts/close-obs-studio.ps1 b/Scripts/close-obs-studio.ps1 new file mode 100644 index 00000000..4e717519 --- /dev/null +++ b/Scripts/close-obs-studio.ps1 @@ -0,0 +1,15 @@ +<# +.SYNOPSIS + Closes OBS Studio +.DESCRIPTION + This script closes the OBS Studio application gracefully. +.EXAMPLE + PS> ./close-obs-studio +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +taskkill /im obs64.exe +exit 0 # success diff --git a/Scripts/open-obs-studio.ps1 b/Scripts/open-obs-studio.ps1 new file mode 100644 index 00000000..5e63e2e0 --- /dev/null +++ b/Scripts/open-obs-studio.ps1 @@ -0,0 +1,28 @@ +<# +.SYNOPSIS + Launches OBS Studio +.DESCRIPTION + This script launches the OBS Studio application. +.EXAMPLE + PS> ./open-obs-studio +.NOTES + Author: Markus Fleschutz · License: CC0 +.LINK + https://github.com/fleschutz/PowerShell +#> + +function TryLaunching { param($Path) + if (test-path "$Path" -pathType leaf) { + start-process "$Path" + exit 0 # success + } +} + +try { + TryLaunching "C:\Program Files (x86)\OBS Studio\bin\64bit\obs64.exe" + TryLaunching "C:\Program Files\OBS Studio\bin\64bit\obs64.exe" + exit 0 # success +} catch { + "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" + exit 1 +}