Skip to content

Use 64 Bit Terminals on 64 WIndows #7095

Closed

Description

  • VSCode Version: 1.2.0-Insiders
  • OS Version: Windows 10

Steps to Reproduce:

  1. The terminal opened by default is the 32bit terminal for cmd.exe or Powershell.exe
  2. On 64 Bit OS Code should be interacting with the sysnative variants.

There is a sort of work around by adding the sysnative path like below, but this should be handled by default. The PowerShell Extension does this for it's terminal session.

{
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
}

Using 32bit breaks a lot of modules and also causes issues when testing your code. PSReadLine is an example of one Module that breaks. One example that could cause problems in your code, is if you are testing something with parts of the registry, the 32 bit console is going to give you bad results since it will be giving you results for the wow3264Node instead.

Activity

  1. changed the title [-]Use 64 Bit Terminals on 64 Bit OSes on WIndows[/-] [+]Use 64 Bit Terminals on 64 WIndows[/+] on Jun 1, 2016
  2. Tyriar commented on Jun 1, 2016

    @Tyriar
    Contributor

    Brandon Padgett (@gerane) see my comments on #6684 (comment) about my experiences with 64-bit powershell, back when powershell was the default.

    Right now the default is %COMSPEC% which defines the default terminal for the environment, if powershell.exe or cmd.exe is used, it's grabbed off the path. So we're leaving it up to powershell and windows which bitness is selected.

  3. gerane commented on Jun 1, 2016

    @gerane
    Author

    Daniel Imms (@Tyriar) On Windows, this is not going to be the desired way for this to function. Is it planned to be changed?

    %SystemRoot%\sysnative does not actually exist, it functions as a folder redirect for 64bit systems. So if a 64bit system uses %SystemRoot%\sysnative it is reditected to %SystemRoot%\System32.

    %SystemRoot%\SysWOW64 is actually what is being executed when running in a 32bit process on a 64bit machine. A 32 process targeting %SystemRoot%\System32 is redirected to %SystemRoot%\SysWOW64 and is the root of the problems. For a 32 bit process to actually run %SystemRoot%\System32, it has to use %SystemRoot%\Sysnative redirect. There are countless issues this will cause in the long run, any many of them may be silent to the end user. They may not find out until their code gets closer to production.

    Here is a shorter diagram:

    *32Bit on 64Bit >> %SystemRoot%\System32\ >> %SystemRoot%\SysWOW64*
    *32Bit on 32Bit >> %SystemRoot%\System32\ >> %SystemRoot%\System32*
    *32Bit on 64Bit >> %SystemRoot%\Sysnative\ >> %SystemRoot%\System32*

  4. Tyriar commented on Jun 1, 2016

    @Tyriar
    Contributor

    Thanks for the info Brandon Padgett (@gerane), really useful!

    So you would suggest that getWindowsShell, which powers both internal and external terminals, becomes "%SystemRoot%\sysnative\cmd.exe" or something similar? After the environment variable is resolved, querying c:\Windows\sysnative\cmd.exe should work?

    Then maybe add a note about %SystemRoot%\sysnative in the Windows shell config descriptions? I'd prefer to avoid messing with the paths that users enter in their settings.json.

  5. gerane commented on Jun 1, 2016

    @gerane
    Author

    Daniel Imms (@Tyriar) I am not very familiar with TS or JS, so I can't show you exactly how it would function in getWindowsShell. I mainly interact with PowerShell and a tiny bit of C#.

    You would need to check the OS Arch and Process Arch, or since code doesn't have a 64 bit client, just check OS Arch, and if 64bit use sysnative. You can test this out by opening both %SystemRoot%\System32\cmd.exe and %SystemRoot%\syswow64\cmd.exe to see how these act.

    Sysnative does not exist for a session that has normal access to %SystemRoot%\System32\. So 64bit Process on 64bit OS and 32bit Process on 32bit OS can't use sysnative. Sysnative is just for use for 32 bit processes on a 64 bit OS.

    If you use C:\Windows\syswow64\cmd.exe and run dir %SystemRoot%\sysnative\ it will return the contents of a C:\windows\sysnative\ directory even though it really doesn't exist. It is actually returning the contents of C:\windows\system32\.

    Then if you use C:\windows\system32\cmd.exe and run dir %SystemRoot%\sysnative\ you get a File Not Found error.

    I just wanted to bring up that this is a bigger issue on Windows than most realize. I have been heavily burned by this in the past and it cost me months of my time and a lot of gray hairs. I just wanted to try to help others avoid the same issues I have gone through in the past. Sometimes you don't realize an issue is even present until after the damage is done when dealing with Windows 32 bit redirections.

    Even just running normal command line tools it is executing the 32bit versions instead of the 64 bit versions which could have some undesired results. Just look at reg.exe for example, most people don't use it's /reg:32 or /reg:64 flags, so it might not target the key they think it is targeting.

  6. added
    feature-request
    terminal
    windows
    on Jun 1, 2016
  7. Tyriar commented on Jun 1, 2016

    @Tyriar
    Contributor

    Ok, well I guess resolving this will involve:

    • Using a 64-bit terminal if available over %COMSPEC% as the default for internal and external terminals
    • (Maybe) Add a note to the config descriptions to guide Powershell users to choosing the correct bitness.
  8. Tyriar commented on Jul 15, 2016

    @Tyriar
    Contributor

    Brandon Padgett (@gerane) do you know how far back in Windows support for sysnative goes? Would it be reasonable to just set the default to c:\\Windows\\sysnative\\cmd.exe or would that fail on Windows 7 or something?

  9. Tyriar commented on Jul 15, 2016

    @Tyriar
    Contributor

    Just added this to settings:

    image

  10. gerane commented on Sep 19, 2016

    @gerane
    Author

    Daniel Imms (@Tyriar) sysnative is only present on 64 bit Windows. So you would have to determine what platform you are running on. Sysnative won't exist on 32bit Windows.

    I think the comment should help those who are going to change it. Would it be beneficial to include a link to information about it? I know it is a confusing topic, and I even regularly see people offering advice on stack overflow or other forums that is incorrect. They often mix the paths up etc.

  11. Tyriar commented on Sep 19, 2016

    @Tyriar
    Contributor

    I'd prefer not to include a link to it, help is always available from our website if needed. After a few months to think about this, while it's tempting to hard code either sysnative on 64bit systems or system32 on 32-bit systems, that would break the %COMSPEC% feature which has been explicitly requested in the past. I think the comment is a good compromise and I haven't seen too many issues come in to do with bitness since so I think I'll close this one off.

  12. shabbi75 commented on Jan 27, 2017

    @shabbi75

    Hi,

    I am facing the same problem, What is the solution for this? thanks.

  13. shabbi75 commented on Jan 27, 2017

    @shabbi75

    Thanks Tyriar for your kind reply. Really appreciate, but I dont see the folder "sysnative" in my windows folder, loioking forward to your further help, thanks.

  14. Tyriar commented on Jan 27, 2017

    @Tyriar
    Contributor

    It's a special folder that you can't see in windows explorer, put it in your config and it should work on a 64-bit machine.

  15. shabbi75 commented on Jan 27, 2017

    @shabbi75

    Thanks, could you please provide this information in detail that which config I need to change, thanks. I dont have any information for that, thanks.

  16. Tyriar commented on Jan 27, 2017

    @Tyriar
    Contributor

    For 64-bit powershell, add this to your settings.json file (File > Preferences > Settings):

    "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
  17. shabbi75 commented on Jan 28, 2017

    @shabbi75

    Sorry, am bothering you a lot.

    I have searched my system and found below files, could you please advise me which one I need to change, thanks.

    image

    Best Regards,
    Shabber Abbas Rizvi

  18. Tyriar commented on Jan 28, 2017

    @Tyriar
    Contributor

    You open it from within the applications file menu.

  19. shabbi75 commented on Jan 29, 2017

    @shabbi75

    I don't see this please

    image

  20. Tyriar commented on Jan 29, 2017

    @Tyriar
    Contributor

    That is visual studio, not visual studio code. Different product.

  21. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestterminalwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions