Choosing default for bash in cmd


  1. Posts : 12
    10
       #1

    Choosing default for bash in cmd


    Hi all,

    I have installed git before, so as a side effect, mingw is also installed. Currently, if I type bash in cmd, I got in bash provided by mingw.
    Now I want to activate Linux subsystem on windows 10. The question is, can I set the default or configure what the bash command in cmd should do (either active Linux subsystem or get into mingw).

    Bests, bbbhh
      My Computer


  2. Posts : 93
    Windows 10
       #2

    Hello,

    On the Windows command line, if you know you have two commands with the same name available for use on your system, the one listed first in the Path environment variable will be used. However, if it exists, the one residing in the current directory will take precedence.

    Enabling the Windows Subsystem for Linux places a bash.exe binary in C:\Windows\System32. This will be the bash instance used if an executable named “bash” doesn’t exist in any of the paths listed before C:\Windows\System32 in the Path. But if your command prompt is open at C:\Windows\System32, C:\Windows\System32\bash.exe will be used regardless of bash-es in the Path.

    You can view the Path variable on the command prompt by echo-ing it.
    Code:
    C:\Users\Pyprohly>echo %path%
    C:\Program Files (x86)\Parallels\Parallels Tools\Applications;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Users\Pyprohly\AppData\Local\Microsoft\WindowsApps
    
    C:\Users\Pyprohly>echo %path:;=&echo(%
    C:\Program Files (x86)\Parallels\Parallels Tools\Applications
    C:\Program Files (x86)\Intel\iCLS Client\
    C:\Program Files\Intel\iCLS Client\
    C:\WINDOWS\system32
    C:\WINDOWS
    C:\WINDOWS\System32\Wbem
    C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    C:\Program Files\dotnet\
    C:\Users\Pyprohly\AppData\Local\Microsoft\WindowsApps
    
    C:\Users\Pyprohly>
    Sometimes you may need to reorder the Path if a particular instance of a command being used isn’t the one you need quick access to. Editing the Path variable can be done through Control Panel > System and Security > System > Advanced system settings > Environment Variables….

    A quick and easy way to determine which instance of a command will be used for the current command prompt session is to use the where command. E.g.,
    Code:
    C:\Users\Pyprohly>where bash
    C:\Windows\System32\bash.exe
    C:\Windows\bash.bat
    The first one listed is the one that will be used if the command was to be typed.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:35.
Find Us




Windows 10 Forums