I can start Windows Terminal with wt
. I have read the Windows Terminal documentation on command-line arguments, and it just covers passing an argument for setting up terminal panes, not passing in actual executable commands.
For example, a minimal reproducible example: Requires Windows Terminal installed:
Open a CMD prompt in Windows and type:
dir | wt
This starts Windows Terminal, but it does not receive the dir
command. How does one pass the executable command to Windows Terminal?
You can test command line arguments by running an executable from the "Command Prompt" in Windows or from the "DOS prompt" in older versions of Windows. You can also use command line arguments in program shortcuts, or when running an application by using Start -> Run. This will start notepad with a blank document.
To start using WSL, open up a PowerShell terminal and type wsl . If you've set up WSL correctly, you'll enter a bash terminal running on the WSL distro of choice. From here, you can run any Linux commands you wish.
Type "start [filename.exe]" into Command Prompt, replacing "filename" with the name of your selected file. Replace "[filename.exe]" with your program's name. This allows you to run your program from the file path.
Use
wt new-tab -p "Command Prompt" -d "%cd%" cmd /k dir
You can omit new-tab
(it’s a default command).
Omitting -d "%cd%"
seems to be equivalent to -d "%USERPROFILE%"
.
You can omit -p "Command Prompt"
if your default profile is set to the cmd.exe profile. Check the wt
settings in the following file (Windows):
%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
Try a more complex command than dir
, for instance
wt new-tab -p "Command Prompt" -d "%cd%" cmd /k "dir & type "%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json""
Please check the How to pass commands into the shell opened in new Windows Terminal question as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With