vscode tasks – How to run code in Visual Studio Code using portable executables (outside environment variables) with a button click?

I prefer to keep my environment variables clean and minimal. Because I frequently add and remove programming language translators (compilers, interpreters, etc.) on my Windows 11 system, I exclusively use portable versions of these tools. This allows me to have better control over my environment, avoid uninstallation leftovers, and avoid cluttering system-wide settings.
However, this means that to run code in Visual Studio Code, I would typically need to type the full path to my portable executable in the terminal every time, followed by my code file. For example:

C:\PortablePython\python.exe myscript.py

This is tedious, and I’m looking for a way to streamline this process within VS Code.

Desired Outcome:
I want to set up Visual Studio Code so that I can run my code (any language, not looking for a language-specific solution) with a simple button click (like the “Run” button) without having to manually type the full path to my portable programming language translator in the terminal each time.

What I’ve Tried:
I explored using VS Code language specific extensions that offer options to specify custom paths for executables. While some extensions do provide this functionality, they often come with a lot of other features and configurations that I don’t need or want to deal with. I’m looking for a more manual and tailored solution if possible.

Question:
Is there a way to configure Visual Studio Code, perhaps using built-in features like tasks or launch configurations, to achieve this “button click” execution of code using portable executables that are not in my environment variables? Ideally, the solution should be general and not tied to a specific programming language.
Example configurations or step-by-step instructions would be greatly appreciated!

Read more here: Source link