Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

code.exe ignoring command-line arguments

I hope this is an easy fix, but I couldn't find any documentation or other posts on the matter. I'm trying to write a script (cmd or pwsh) that will launch vscode with my preferences on a portable install.

When trying to execute vscode's code.exe with any arguments, it ignores them and just launches the program as if I had typed nothing else. I'm following this doc in my testing. Using alias switches doesn't work, either. The only argument that does seem to process is if I include a path.

code.exe --help
code.exe --version

Additionally, after launching code.exe, the console kind of hangs, then vscode status messages are sent to that console (even without use of the --wait switch). If I close the console, vscode shuts down. Is there a way to work around this?

like image 263
Maximilian Burszley Avatar asked Jan 31 '18 19:01

Maximilian Burszley


People also ask

How do I run an exe from command line arguments?

For example, entering C:\abc.exe /W /F on a command line would run a program called abc.exe and pass two command line arguments to it: /W and /F.

What happens if we run the program without passing the command line arguments?

The java executable passes an empty array of type String to the main method if no command line arguments are passed.

Can you pass command line arguments?

It is possible to pass some values from the command line to your C programs when they are executed. These values are called command line arguments and many times they are important for your program especially when you want to control your program from outside instead of hard coding those values inside the code.

How do you give command line arguments in Visual Studio code?

To set command-line arguments in Visual Studio, right click on the project name, then go to Properties. In the Properties Pane, go to "Debugging", and in this pane is a line for "Command-line arguments." Add the values you would like to use on this line. They will be passed to the program via the argv array.


1 Answers

When using Code via shell (cmd or pwsh), it does not use Code.exe, but the script/batch files located under Bin folder (code.cmd). These are the applications which really recognizes the command line switches.

This is not entirely clear in the Command Line Documentation page, but looking closer at the Note you will see that it does say the Program Files\Microsoft VS Code\bin folder.

like image 136
alefragnani Avatar answered Sep 17 '22 17:09

alefragnani