How it works...
The cmdlet, Start-Process, works with paths. In the case of code, though, Linux knows the path where the package is installed. Therefore, simply calling the package by command is sufficient.
The Visual Studio Code process accepts the directory/file location as input. Therefore, we add the ArgumentList parameter and pass the path to the process as an argument. This opens that directory in Visual Studio Code.
Stopping a process requires a .NET object as input by default; Stop-Process would not accept a string as the default input. Therefore, we enclose the Get-Process cmdlet within parentheses, so that it gets executed first and outputs a System.Diagnostics.Process object, which is then processed by Stop-Process.
In order to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access