Bad cmd.exe is executed when terminal is opened as admin #13433

Closed
opened 2026-01-31 03:42:33 +00:00 by claunia · 9 comments
Owner

Originally created by @rhsCZ on GitHub (Apr 14, 2021).

Windows Terminal version (or Windows build number)

1.6.10571.0

Other Software

Windows Command prompt ver. 10.0.19042.867

Steps to reproduce

Run Windows terminal as admin and 64bit Win 10, using default settings

Expected Behavior

to always run C:\Windows\System32\cmd.exe

Actual Behavior

when i choose to run Command Prompt it runs C:\Windows\SysWOW64\cmd.exe which can't run anything from C:\Windows\System32 even if it is in %PATH% but only from C:\Windows\SysWOW64

Originally created by @rhsCZ on GitHub (Apr 14, 2021). ### Windows Terminal version (or Windows build number) 1.6.10571.0 ### Other Software Windows Command prompt ver. 10.0.19042.867 ### Steps to reproduce Run Windows terminal as admin and 64bit Win 10, using default settings ### Expected Behavior to always run C:\Windows\System32\cmd.exe ### Actual Behavior when i choose to run Command Prompt it runs C:\Windows\SysWOW64\cmd.exe which can't run anything from C:\Windows\System32 even if it is in %PATH% but only from C:\Windows\SysWOW64
claunia added the Needs-TriageNeeds-Tag-FixNeeds-Attention labels 2026-01-31 03:42:34 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Apr 14, 2021):

How did you install the Terminal? From the Store, from the github releases, from a package manager...?

@zadjii-msft commented on GitHub (Apr 14, 2021): How did you install the Terminal? From the Store, from the github releases, from a package manager...?
Author
Owner

@rhsCZ commented on GitHub (Apr 14, 2021):

From store

@rhsCZ commented on GitHub (Apr 14, 2021): From store
Author
Owner

@DHowett commented on GitHub (Apr 14, 2021):

Can you share a screenshot (or two) of PATH as represented by your system and user environment variable settings?

I'd like to see the originals (as checking from the shell might represent nonreality)

@DHowett commented on GitHub (Apr 14, 2021): Can you share a screenshot (or two) of PATH as represented by your system and user environment variable settings? I'd like to see the originals (as checking from the shell might represent nonreality)
Author
Owner

@rhsCZ commented on GitHub (Apr 14, 2021):

env1
env2
env3

@rhsCZ commented on GitHub (Apr 14, 2021): ![env1](https://user-images.githubusercontent.com/15573547/114738386-34902480-9d48-11eb-9772-9f5bafb026f8.png) ![env2](https://user-images.githubusercontent.com/15573547/114738389-3528bb00-9d48-11eb-9f90-87bb970fda20.png) ![env3](https://user-images.githubusercontent.com/15573547/114738392-3528bb00-9d48-11eb-844c-3440aac13809.png)
Author
Owner

@DHowett commented on GitHub (Apr 14, 2021):

Huh.. okay, one more question. From powershell (outside terminal!), can you run gcm cmd -all

This is the last of the easy troubleshooting steps before I start asking for Process Monitor logs 😄

@DHowett commented on GitHub (Apr 14, 2021): Huh.. okay, one more question. From _powershell_ (outside terminal!), can you run `gcm cmd -all` This is the last of the easy troubleshooting steps before I start asking for Process Monitor logs :smile:
Author
Owner

@rhsCZ commented on GitHub (Apr 14, 2021):

ps

@rhsCZ commented on GitHub (Apr 14, 2021): ![ps](https://user-images.githubusercontent.com/15573547/114743263-cc900d00-9d4c-11eb-858a-c1cf0b696d48.png)
Author
Owner

@rhsCZ commented on GitHub (Apr 16, 2021):

I found something interesting, because i'm lazy always clicking run as admin. so i made small program(its only launch terminal as admin and exits), which works fine. its called wtadmin.exe. So i placed my program in C:\Windows\System32 and if i launch terminal via my program placed in System32 or SysWow64 it wierdly launches cmd.exe from SysWow64 but when i place my program for example in C:\Windows it woks normally. This behaviour is only if my program is compiled as 32bit. but works normally when compiled as 64bit and placed in C:\Windows\System32. I looked at process enviroment variables but they look almost same, PROCESSOR_ARCHITEW6432=AMD64 is set in buggy enviroment.
. i don't understand this behavior.

@rhsCZ commented on GitHub (Apr 16, 2021): I found something interesting, because i'm lazy always clicking run as admin. so i made small program(its only launch terminal as admin and exits), which works fine. its called wtadmin.exe. So i placed my program in C:\Windows\System32 and if i launch terminal via my program placed in System32 or SysWow64 it wierdly launches cmd.exe from SysWow64 but when i place my program for example in C:\Windows it woks normally. This behaviour is only if my program is compiled as 32bit. but works normally when compiled as 64bit and placed in C:\Windows\System32. I looked at process enviroment variables but they look almost same, PROCESSOR_ARCHITEW6432=AMD64 is set in buggy enviroment. . i don't understand this behavior.
Author
Owner

@rhsCZ commented on GitHub (Apr 16, 2021):

Sorry for everything because it was my fault. i totally forgot about filesystem redirection of System32 to SysWOW64 for 32 bit apps under 64 bit OS. So working directory of WindowsTerminal.exe was set to C:\Windows\SysWOW64, so that was why it launched cmd.exe from SySWOW64 Directory. I dont know about these variables(PROCESSOR_ARCHITEW6432=AMD64 and PROCESSOR_ARCHITECTURE=x86) if it has any effect for 64bit app, because they should be set, as i mentioned earlier, only for 32 bit app under 64 bit OS. Once more very sorry about that. I'm learning programming, so sorry about everything.

@rhsCZ commented on GitHub (Apr 16, 2021): Sorry for everything because it was my fault. i totally forgot about filesystem redirection of System32 to SysWOW64 for 32 bit apps under 64 bit OS. So working directory of WindowsTerminal.exe was set to C:\Windows\SysWOW64, so that was why it launched cmd.exe from SySWOW64 Directory. I dont know about these variables(PROCESSOR_ARCHITEW6432=AMD64 and PROCESSOR_ARCHITECTURE=x86) if it has any effect for 64bit app, because they should be set, as i mentioned earlier, only for 32 bit app under 64 bit OS. Once more very sorry about that. I'm learning programming, so sorry about everything.
Author
Owner

@DHowett commented on GitHub (Apr 16, 2021):

No need to apologize! We do weird stuff all the time 😄

@DHowett commented on GitHub (Apr 16, 2021): No need to apologize! We do weird stuff all the time :smile:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13433