Create distinction between Visual Studio Instances (e.g. 2022 vs 2017) in Powershell

On my Win11 PC I run two instances of Visual Studio concurrently. 2017 version for an 'API.cs' and 2022 version to run 'program.cs'.
Recently I had 'program.cs' hang on me, so I opened Powershell to kill it. Using the cmdlet 'gps | ? {$_.mainwindowtitle.length -ne 0}' I was presented with the below list, which showed no obvious distinction between the two instances:
Handles | NPM(K) | PM(K) | WS(K) | CPU(s) | Id | SI | ProcessName |
---|---|---|---|---|---|---|---|
3194 | 250 | 347272 | 389452 | 716.00 | 15584 | 1 | devenv |
4421 | 336 | 1411480 | 1588320 | 140.19 | 17116 | 1 | devenv |
How can I reliably + automatically (either via cmdlet in my .ps1 or by changing an application setting) demarcate VS2017 and VS2022? Alternatively, what argument am I missing that would show extra detail which allows me to select the right instance to (on this occasion) kill VS2022?
Answer
I would start by making sure that API.cs and program.cs are part of different projects. The way I open projects is I pin Visual Studio to the taskbar (you should pin both of your versions). Once you've opened the correct project right right-click on that version of Visual Studio in the taskbar and pin the project to the recent files list. Then all you have to do going forward is right-click on the appropriate version of Visual Studio and left-click on the desired project.
If you want to make your two versions of Visual Studio look vastly different you can customized their icons:
Enjoyed this article?
Check out more content on our blog or follow us on social media.
Browse more articles