An app instance can be modified when it is run with a command-line switch. The switch tells the app to run in a particular state or to disable a certain feature when it runs. The change isn’t permanent and only subject to that one instance when the app is run.
A command-line switch is basically an argument that is sent to an app or script. The app doesn’t necessarily have to be a command-line app. GUI desktop apps like Chrome can also be used with command-line switches. In fact, browsers are one of the most common desktop apps to be used with them.
In order to run an app with a command-line switch, the app itself must support them. You cannot invent a switch or use one from a different app. It is strictly subject to what an app does and does not support.
There are two ways to use a command-line switch on Windows 10.
Use Command-line switch – Command Prompt
To use a command-line switch from the Command Prompt, you need to first find the switch that you will use. For this, we’re going to use Chrome as an example.
- Open Command Prompt.
- Use the cd command to move to the folder with the EXE or shortcut to the app you want to run with a switch
cd "path to EXE or shortcut"
- Use the following syntax to open the app with the switch.
or for a shortcut to an app;
"Google Chrome.lnk" --incognito
Use Command-line switch – Shortcut
An app’s shortcut can be modified so that when it is used to open the app, it runs with a command-line argument. Again, we’re using Chrome for our example.
- Create a shortcut to the app you want to run with a Command-line switch. You can drag & drop it onto the desktop from the Apps list in the Start menu or right-click it and select the desktop option from the context menu.
- Once you have a shortcut, right-click it and select Properties.
- Go to the Shortcut tab and click inside the Target field.
- At the very end of the path in the Target field, add one space.
- Add two dashes, and enter the switch (see example below)
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --incognito
- Click Apply and close the Properties window.
- Use the shortcut to open the app, and it will run with the command-line switch you added.
A command-line switch is a convenient way to change the behavior of an app without making it permanent. The switch only modifies the app’s instance for the one time it is used to run it. If you use the shortcut method instead of the Command Prompt method, you will always have a quick way to run the app with a switch without having to type it out each time.
You can use the Task Manager to see if an app is running with a Command-Line switch.