Shell launch arguments are not respected #2556

Closed
opened 2026-01-30 22:58:18 +00:00 by claunia · 12 comments
Owner

Originally created by @rasmuskriest on GitHub (Jul 4, 2019).

Currently, Windows Terminal does not respect shell launch arguments. According to the SettingsSchema.md, commandline is the the only link to the shell executable. An additional property similiar to startingDirectory, i.e. launchArguments, could fix this problem.

Environment

Windows build number: 18362.207
Windows Terminal version: 0.2.1831.0

Steps to reproduce

  1. Create a profile with launch arguments, e.g. "commandline": "powershell.exe -noprofile" or "commandline": "wsl.exe -e vi".
  2. Launch the newly created profile.

Expected behavior

The shell should start with the launch arguments in mind, e.g. without sourcing $Profile or directly starting into vi.

Actual behavior

The shell is being started as if no launch argument had been passed.

Originally created by @rasmuskriest on GitHub (Jul 4, 2019). Currently, Windows Terminal does not respect shell launch arguments. According to the [SettingsSchema.md](https://github.com/microsoft/terminal/blob/master/doc/cascadia/SettingsSchema.md#profiles), `commandline` is the the only link to the shell executable. An additional property similiar to `startingDirectory`, i.e. `launchArguments`, could fix this problem. # Environment ```none Windows build number: 18362.207 Windows Terminal version: 0.2.1831.0 ``` # Steps to reproduce 1. Create a profile with launch arguments, e.g. `"commandline": "powershell.exe -noprofile"` or `"commandline": "wsl.exe -e vi"`. 2. Launch the newly created profile. # Expected behavior The shell should start with the launch arguments in mind, e.g. without sourcing `$Profile` or directly starting into `vi`. # Actual behavior The shell is being started as if no launch argument had been passed.
claunia added the Needs-TriageNeeds-Tag-Fix labels 2026-01-30 22:58:18 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 4, 2019):

It definitely does. This is how the auto generated WSL distribution profiles work (wsl -d DistributionName)!

@DHowett-MSFT commented on GitHub (Jul 4, 2019): It definitely does. This is how the auto generated WSL distribution profiles work (`wsl -d DistributionName`)!
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 5, 2019):

Quick question: when you add these new profiles, are you making sure to generate a new GUID? Otherwise, you’ll end up launching the wrong profile by mistake.

@DHowett-MSFT commented on GitHub (Jul 5, 2019): Quick question: when you add these new profiles, are you making sure to generate a new GUID? Otherwise, you’ll end up launching the wrong profile by mistake.
Author
Owner

@rasmuskriest commented on GitHub (Jul 6, 2019):

Of couse I did! The following is the two PowerShell profiles, both load $Profile upon launch.

    {
      "acrylicOpacity": 0.75,
      "closeOnExit": true,
      "colorScheme": "Campbell",
      "commandline": "powershell.exe",
      "startingDirectory": "$HOME",
      "cursorColor": "#FFFFFF",
      "cursorShape": "bar",
      "fontFace": "Fira Code",
      "fontSize": 11,
      "guid": "{40ca93c2-50a8-468a-8622-bb2c92a06618}",
      "historySize": 9001,
      "name": "Windows PowerShell",
      "padding": "0, 0, 0, 0",
      "snapOnInput": true,
      "useAcrylic": true,
      "icon": "ms-appdata:///Roaming/powershell.png"
    },
    {
      "acrylicOpacity": 0.75,
      "closeOnExit": true,
      "colorScheme": "Campbell",
      "commandline": "powershell.exe -noprofile",
      "startingDirectory": "$HOME",
      "cursorColor": "#FFFFFF",
      "cursorShape": "bar",
      "fontFace": "Fira Code",
      "fontSize": 11,
      "guid": "{93ac7c35-ebe9-42af-b6d2-7b56dc90d8bb}",
      "historySize": 9001,
      "name": " Windows PowerShell (no profile)",
      "padding": "0, 0, 0, 0",
      "snapOnInput": true,
      "useAcrylic": true,
      "icon": "ms-appdata:///Roaming/powershell.png"
    },

I might do an app reset later this weekend and start over with a newly created settings.json, maybe that helps.

@rasmuskriest commented on GitHub (Jul 6, 2019): Of couse I did! The following is the two PowerShell profiles, both load `$Profile` upon launch. ``` json { "acrylicOpacity": 0.75, "closeOnExit": true, "colorScheme": "Campbell", "commandline": "powershell.exe", "startingDirectory": "$HOME", "cursorColor": "#FFFFFF", "cursorShape": "bar", "fontFace": "Fira Code", "fontSize": 11, "guid": "{40ca93c2-50a8-468a-8622-bb2c92a06618}", "historySize": 9001, "name": "Windows PowerShell", "padding": "0, 0, 0, 0", "snapOnInput": true, "useAcrylic": true, "icon": "ms-appdata:///Roaming/powershell.png" }, { "acrylicOpacity": 0.75, "closeOnExit": true, "colorScheme": "Campbell", "commandline": "powershell.exe -noprofile", "startingDirectory": "$HOME", "cursorColor": "#FFFFFF", "cursorShape": "bar", "fontFace": "Fira Code", "fontSize": 11, "guid": "{93ac7c35-ebe9-42af-b6d2-7b56dc90d8bb}", "historySize": 9001, "name": " Windows PowerShell (no profile)", "padding": "0, 0, 0, 0", "snapOnInput": true, "useAcrylic": true, "icon": "ms-appdata:///Roaming/powershell.png" }, ``` I might do an app reset later this weekend and start over with a newly created `settings.json`, maybe that helps.
Author
Owner

@rasmuskriest commented on GitHub (Jul 6, 2019):

Just did the reset and gradually pasted my old profiles into the new settings.json, everything seems to work now. Tested on two machines (same Microsoft account, so synced settings) on which the problem was present.

Also, I ran an independent JSON Validator on the old settings file (just in case VS Code might not highlight something), no errors whatsoever. Strange!

@rasmuskriest commented on GitHub (Jul 6, 2019): Just did the reset and gradually pasted my old profiles into the new `settings.json`, everything seems to work now. Tested on two machines (same Microsoft account, so synced settings) on which the problem was present. Also, I ran an independent JSON Validator on the old settings file (just in case VS Code might not highlight something), no errors whatsoever. Strange!
Author
Owner

@zadjii-msft commented on GitHub (Jul 8, 2019):

@rasmuskriest I'm 99% sure that Powershell-style environment variables won't work - instead of using $HOME try %HOME% (though, you'll need to have a %home% environment variable set).

I don't think that's what was causing your problem, but it's something I noticed looking through your profiles.

@zadjii-msft commented on GitHub (Jul 8, 2019): @rasmuskriest I'm 99% sure that Powershell-style environment variables won't work - instead of using `$HOME` try `%HOME%` (though, you'll need to have a %home% environment variable set). I don't think that's what was causing your problem, but it's something I noticed looking through your profiles.
Author
Owner

@jbtibor commented on GitHub (Jul 11, 2019):

Is it allowed to use path in startingDirectory? Tried and is not applied.
I.e. "startingDirectory" : "C:\temp",

@jbtibor commented on GitHub (Jul 11, 2019): Is it allowed to use path in startingDirectory? Tried and is not applied. I.e. `"startingDirectory" : "C:\temp",`
Author
Owner

@rasmuskriest commented on GitHub (Jul 11, 2019):

@zadjii-msft Thanks for the heads up - guess that I simply did not notice yet because of the default (fallback?) being %USERPROFILE%.

@jbtibor: #1555 and #1836 give some good explanation and instructions on how this works.

@rasmuskriest commented on GitHub (Jul 11, 2019): @zadjii-msft Thanks for the heads up - guess that I simply did not notice yet because of the default (fallback?) being `%USERPROFILE%`. @jbtibor: #1555 and #1836 give some good explanation and instructions on how this works.
Author
Owner

@jbtibor commented on GitHub (Jul 13, 2019):

Let me translate rasmuskriest's answer :-) Path has to be ended with path separator, i.e.
"startingDirectory" : "C:\temp\",

Thank you.

@jbtibor commented on GitHub (Jul 13, 2019): Let me translate rasmuskriest's answer :-) Path has to be ended with path separator, i.e. `"startingDirectory" : "C:\temp\",` Thank you.
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 13, 2019):

No, path must be escaped because you’re putting it in a JSON document. c:\\temp

@DHowett-MSFT commented on GitHub (Jul 13, 2019): No, path must be escaped because you’re putting it in a JSON document. `c:\\temp`
Author
Owner

@jbtibor commented on GitHub (Jul 13, 2019):

Of course is escaped, otherwise settings wouldn't load. The reason startingDirectory wasn't applied was that path didn't have trailing path separator.

@jbtibor commented on GitHub (Jul 13, 2019): Of course is escaped, otherwise settings wouldn't load. The reason startingDirectory wasn't applied was that path didn't have trailing path separator.
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 13, 2019):

We don’t require that the path have a trailing path separator, though. Can you share the snippet of JSON that isn’t working for you?

@DHowett-MSFT commented on GitHub (Jul 13, 2019): We don’t require that the path have a trailing path separator, though. Can you share the snippet of JSON that isn’t working for you?
Author
Owner

@jbtibor commented on GitHub (Jul 13, 2019):

I already did.
This isn't applied, PS opens in user profile, C:\Users\MyUserName
"startingDirectory": "C:\\temp",

This is applied, PS opens in C:\temp
"startingDirectory": "C:\\temp\\",

Windows 10, Terminal 0.2.1831.1

See #1555

@jbtibor commented on GitHub (Jul 13, 2019): I already did. This isn't applied, PS opens in user profile, C:\Users\MyUserName `"startingDirectory": "C:\\temp",` This is applied, PS opens in C:\temp `"startingDirectory": "C:\\temp\\",` Windows 10, Terminal 0.2.1831.1 See #1555
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2556