Update open-outlook.ps1 and open-thunderbird.ps1

This commit is contained in:
Markus Fleschutz 2021-12-13 08:55:50 +01:00
parent 1d228e8fb5
commit 506ceb0fd6
2 changed files with 22 additions and 11 deletions

View File

@ -11,18 +11,18 @@
https://github.com/fleschutz/PowerShell
#>
function TryLaunching { param($Path)
if (test-path "$Path" -pathType leaf) {
start-process "$Path"
exit 0 # success
}
function TryToExec { param($Folder, $Binary)
if (test-path "$Folder/$Binary" -pathType leaf) {
start-process "$Folder/$Binary" -WorkingDirectory "$Folder"
exit 0 # success
}
}
try {
TryLaunching "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE"
TryLaunching "C:\Programs\Microsoft Office\Office14\OUTLOOK.EXE"
exit 0 # success
TryToExec "C:\Program Files\Microsoft Office\root\Office16" "OUTLOOK.EXE"
TryToExec "C:\Programs\Microsoft Office\Office14" "OUTLOOK.EXE"
throw "It seems Outlook isn't installed yet."
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
& "$PSScriptRoot/give-reply.ps1" "Sorry: $($Error[0])"
exit 1
}

View File

@ -11,5 +11,16 @@
https://github.com/fleschutz/PowerShell
#>
Start-Process "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
exit 0 # success
function TryToExec { param($Folder, $Binary)
if (test-path "$Folder/$Binary" -pathType leaf) {
start-process "$Folder/$Binary" -WorkingDirectory "$Folder"
exit 0 # success
}
}
try {
TryToExec "C:\Program Files (x86)\Mozilla Thunderbird" "thunderbird.exe"
throw "It seems Thunderbird isn't installed yet."
} catch {
& "$PSScriptRoot/give-reply.ps1" "Sorry: $($Error[0])"
}