Developer command prompt for vs 2022 not initialized correctly when using wt command line #20358

Closed
opened 2026-01-31 07:11:21 +00:00 by claunia · 7 comments
Owner

Originally created by @brupelo on GitHub (Aug 11, 2023).

Windows Terminal version

1.17.11461.0

Windows build number

Microsoft Windows [Version 10.0.19045.3208]

Other Software

No response

Steps to reproduce

Make sure you've got installed vs2022 and check that's working properly when using the dropdown menu

WindowsTerminal_dbpls1GK02

You should have available cl, ie: where cl

In order to check this bug open a new terminal with default "Command prompt" profile (no cl available in path) and run:

wt -w main new-tab -p "Developer Command Prompt for VS 2022" --startingDirectory c: --tabCommand cmd.exe dir

You'll see how a new window is created with the right title

WindowsTerminal_Xu5t6MG8Lu

but when i try to do where cl I'll get

where cl
INFO: Could not find files for the given pattern(s).

Expected Behavior

I'd expect the profile being executed and configured properly in the new window

Actual Behavior

Profile hasn't been configured properly in the new window

Originally created by @brupelo on GitHub (Aug 11, 2023). ### Windows Terminal version 1.17.11461.0 ### Windows build number Microsoft Windows [Version 10.0.19045.3208] ### Other Software _No response_ ### Steps to reproduce Make sure you've got installed vs2022 and check that's working properly when using the dropdown menu ![WindowsTerminal_dbpls1GK02](https://github.com/microsoft/terminal/assets/18058492/67ec15ef-912c-4cee-af82-a969c4a7392f) You should have available cl, ie: `where cl` In order to check this bug open a new terminal with default "Command prompt" profile (no cl available in path) and run: >wt -w main new-tab -p "Developer Command Prompt for VS 2022" --startingDirectory c: --tabCommand cmd.exe dir You'll see how a new window is created with the right title ![WindowsTerminal_Xu5t6MG8Lu](https://github.com/microsoft/terminal/assets/18058492/d9339ee3-9c11-47e1-b6ae-3ec7d425fdd6) but when i try to do `where cl` I'll get >where cl INFO: Could not find files for the given pattern(s). ### Expected Behavior I'd expect the profile being executed and configured properly in the new window ### Actual Behavior Profile hasn't been configured properly in the new window
claunia added the Needs-TriageIssue-Bug labels 2026-01-31 07:11:21 +00:00
Author
Owner

@brupelo commented on GitHub (Aug 11, 2023):

Just to let you know I've recently installed

Terminal (Portable)
Version: 1.18.230526002-preview

and the issue still remains in that version

@brupelo commented on GitHub (Aug 11, 2023): Just to let you know I've recently installed Terminal (Portable) Version: 1.18.230526002-preview and the issue still remains in that version
Author
Owner

@237dmitry commented on GitHub (Aug 11, 2023):

no cl available in path

where.exe searches only in the PATH.

@237dmitry commented on GitHub (Aug 11, 2023): > no cl available in path `where.exe` searches only in the PATH.
Author
Owner

@lhecker commented on GitHub (Aug 11, 2023):

Without having further looked into it, I strongly suspect that when you write --tabCommand cmd.exe it breaks the profile. The VS 2022 profile doesn't just run cmd.exe as is after all, but rather:

cmd.exe /k "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -startdir=none -arch=x64 -host_arch=x64

In other words: Your issue will likely be fixed if you don't write --tabCommand cmd.exe.

@lhecker commented on GitHub (Aug 11, 2023): Without having further looked into it, I strongly suspect that when you write `--tabCommand cmd.exe` it breaks the profile. The VS 2022 profile doesn't just run `cmd.exe` as is after all, but rather: ``` cmd.exe /k "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -startdir=none -arch=x64 -host_arch=x64 ``` In other words: Your issue will likely be fixed if you don't write `--tabCommand cmd.exe`.
Author
Owner

@brupelo commented on GitHub (Aug 11, 2023):

@lhecker You're right! I've tried wt -w main new-tab -p "Developer Command Prompt for VS 2022" --startingDirectory . and the profile is not breaking with this syntax.

A little bit more context, from SublimeText i'm able to invoke wt with different profiles and i was using --tabCommand in order to activate my current python virtual environment.

Here's an example of what I mean:

wt -w main new-tab -p "Developer Command Prompt for VS 2022" --startingDirectory C:\Users\Foo --tabCommand cmd.exe /K D:\sources\my_fancy_python_project\venv\Scripts\activate.bat

unfortunately, as you've explained... it seems that tabCommand will break the profile (although the virtualenv becomes activate). Is this a bug? If it's not, what'd be workaround to have both the profile enabled + virtualenv?

@brupelo commented on GitHub (Aug 11, 2023): @lhecker You're right! I've tried `wt -w main new-tab -p "Developer Command Prompt for VS 2022" --startingDirectory .` and the profile is not breaking with this syntax. A little bit more context, from SublimeText i'm able to invoke wt with different profiles and i was using --tabCommand in order to activate my current python virtual environment. Here's an example of what I mean: > wt -w main new-tab -p "Developer Command Prompt for VS 2022" --startingDirectory C:\Users\Foo --tabCommand cmd.exe /K D:\sources\my_fancy_python_project\venv\Scripts\activate.bat unfortunately, as you've explained... it seems that tabCommand will break the profile (although the virtualenv becomes activate). Is this a bug? If it's not, what'd be workaround to have both the profile enabled + virtualenv?
Author
Owner

@lhecker commented on GitHub (Aug 11, 2023):

It's funny that you ask this because this PR just happened to be submitted today: #15822. That would probably help you a lot with making this work. I would recommend subscribing to the corresponding issue #5528 for updates on when it gets released.

But the problem is that I'm not a Python dev and so I'm not sure how to make the VsDevCmd.bat + activate.bat combo work. If the above PR doesn't help you with that, I believe the alternative is for you to write your own "activate.bat" that invokes vswhere.exe to find a Visual Studio installation and then calls the VsDevCmd.bat in the installation directory (just like in my lengthy command above), followed by a call to activate.bat in your project.

In any case, I'll close the issue for now, because this doesn't appear to be a bug. But we can continue discussing it. Maybe someone comes along who has experience with this too... 🙂

@lhecker commented on GitHub (Aug 11, 2023): It's funny that you ask this because this PR just happened to be submitted today: #15822. That would probably help you a lot with making this work. I would recommend subscribing to the corresponding issue #5528 for updates on when it gets released. But the problem is that I'm not a Python dev and so I'm not sure how to make the VsDevCmd.bat + activate.bat combo work. If the above PR doesn't help you with that, I believe the alternative is for you to write your own "activate.bat" that invokes `vswhere.exe` to find a Visual Studio installation and then calls the `VsDevCmd.bat` in the installation directory (just like in my lengthy command above), followed by a call to `activate.bat` in your project. In any case, I'll close the issue for now, because this doesn't appear to be a bug. But we can continue discussing it. Maybe someone comes along who has experience with this too... 🙂
Author
Owner

@rofoto commented on GitHub (Apr 6, 2024):

for anyone stumbling on this or similar errors when using the 'new' windows terminal in the future, you can replace the command in the settings for your version of the developer console with :
'''%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat"'''

this command is just copy/pasted from the shortcut to launch the default Developer command prompt.
copy this:
Screenshot_3
and paste it here:
Screenshot_1

not sure why MS felt the need to use a different command to launch the same thing, but I am sure they had what they think is a good reason to do so. It just doesn't work.

@rofoto commented on GitHub (Apr 6, 2024): for anyone stumbling on this or similar errors when using the 'new' windows terminal in the future, you can replace the command in the settings for your version of the developer console with : '''%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat"''' this command is just copy/pasted from the shortcut to launch the default Developer command prompt. copy this: ![Screenshot_3](https://github.com/microsoft/terminal/assets/13305754/ba9b2aa8-a560-40ce-aaed-d33c0227759f) and paste it here: ![Screenshot_1](https://github.com/microsoft/terminal/assets/13305754/43462337-46b9-4790-8884-906e00f62ed8) not sure why MS felt the need to use a different command to launch the same thing, but I am sure they had what they think is a good reason to do so. It just doesn't work.
Author
Owner

@DHowett commented on GitHub (Apr 6, 2024):

not sure why MS felt the need to use a different command to launch the same thing, but I am sure they had what they think is a good reason to do so. It just doesn't work.

This feature was contributed by somebody on the Visual Studio team.

At the end of the day, you are welcome to configure your profiles whatever way you see fit.

@DHowett commented on GitHub (Apr 6, 2024): > not sure why MS felt the need to use a different command to launch the same thing, but I am sure they had what they think is a good reason to do so. It just doesn't work. This feature was contributed by somebody on the Visual Studio team. At the end of the day, you are welcome to configure your profiles whatever way you see fit.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20358