PowerShell/scripts/open-visual-studio.ps1

29 lines
716 B
PowerShell
Raw Normal View History

2023-10-31 12:48:22 +01:00
<#
.SYNOPSIS
2023-08-24 14:10:36 +02:00
Launches Visual Studio
.DESCRIPTION
2023-08-24 14:10:36 +02:00
This PowerShell script launches the Microsoft Visual Studio application.
.EXAMPLE
2023-08-24 14:10:36 +02:00
PS> ./open-visual-studio.ps1
.LINK
https://github.com/fleschutz/PowerShell
2022-09-06 21:42:04 +02:00
.NOTES
Author: Markus Fleschutz | License: CC0
#>
2023-08-24 14:10:36 +02:00
function tryToLaunch { param($filePath)
if (Test-Path "$filePath" -pathType leaf) {
Start-Process "$filePath"
exit 0 # success
}
}
try {
2023-08-24 14:10:36 +02:00
tryToLaunch "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe"
tryToLaunch "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe"
exit 0 # success
} catch {
2022-04-13 12:06:32 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}