I installed Windows Subsystem for Linux and turned it on under windows turn ON OFF features. And then restarted my Pc. I did check on cmd soon after restarting the PC by typing "wsl" and it works. But when i run my script from its folder which has the command "wsl -e xxx.sh", i get an error

'wsl' is not recognized as an internal or external command, operable program or batch file.

Could you guys help me with it please. Thank you.

My PC is running on Os: Windows 10 Pro; Microsoft windows version: 1903; Os Build: 18362.418

  • Did you try using wsl.exe instead?
    – lol
    Commented Nov 12, 2019 at 16:51
  • Yes tried now still no luck. Now i get the error as "'wsl.exe' is not recognized as an internal or external command, operable program or batch file."
    – anand s
    Commented Nov 12, 2019 at 17:02
  • 1
    Is your script clobbering the PATH? That is the only logical answer that I can think of. AND.. from CMD.EXE, you don't EVER need to add ".exe". Commented Nov 12, 2019 at 17:04
  • Yes @SeñorCMasMas i do believe wsl.exe is not required to be added. just wsl works fine. On normal command line if i type wsl and hit enter, i get ubuntu terminal window
    – anand s
    Commented Nov 12, 2019 at 17:07
  • 1
    1. echo %PATH% from the command line (when it works) 2. echo %PATH% somewhere from within your script. Add a pause statement after if you need to (when it doesn't). 3. Compare the two paths. You will probably find your answer there. Commented Nov 12, 2019 at 17:12

4 Answers 4


The most common reason why a command which runs an executable program works on the command line, but not in a batch script, is that, in the script, prior to the line containing the problem command, the user has created a variable %path%. It might seem a handy name for a variable that holds, well, a path. The problem is that this variable name is used by Windows to hold a semicolon-separated list of folders which are searched when an executable is called. It is a system variable. If you have redefined it, then all executables (e.g. .exe, .bat, .vbs, etc) that Windows uses, will not be found, and the script will fail with exactly this message, where xxx is the program or file that is expected:

'xxx' is not recognized as an internal or external command, operable program or batch file.

This can be confusing because commands which are internal to the cmd environment (dir, cls, set, copy, move, etc) (list here) still continue to work in this situation.

You can debug a script where this is suspected by inserting the path command immediately before a problem line. The Windows path variable starts with these folders, and may be extended as programs are installed:


  • Hi, I check the PATH under Windows path variable, it already had the path %SystemRoot%\system32 So i went back to my script and specified the full path as "wsl -e C:/Users/<user>/setup/xxx.sh" and it worked! Might be silly of me but i realized that the windows linux subsystem command wsl was not able to find the script. And specifying the full path did the trick. Thank you guys for your valuable time to help. Much appreciate it.
    – anand s
    Commented Nov 18, 2019 at 12:01
  • I would add a suggestion to check the variables: windir, SystemDrive, ComSpec, are present, otherwise I would add them, just a tip ..
    – Io-oI
    Commented May 23, 2020 at 14:38

Common problem when trying to access 64-bit tools from 32-bit processes. wsl.exe is in System32. But if your script happens to run as a 32-bit process, then all accesses to System32 are redirected to SysWOW64. In order to access wsl.exe in the "real" System32 folder, you'll have to use Sysnative instead, like in C:\Windows\Sysnative\wsl.exe.

  • Thanks for the great explanation! I had to recompile my app with proper x86_64 architecture to fix the issue.
    – Amin Ya
    Commented May 28, 2021 at 17:56
  • 1
    set path=%path%;C:\Windows\Sysnative fixed the issue for me. I wonder why C:\Windows\Sysnative is not in the path by default.
    – stasoid
    Commented Nov 20, 2021 at 19:42
  • I was trying to run wsl from Vim and this works for me! Thanks!
    – sup39
    Commented Dec 24, 2021 at 7:42

This error is covered in the "Troubleshooting installation" section of the WSL installation guide:

The term 'wsl' is not recognized as the name of a cmdlet, function, script file, or operable program.

Ensure that the Windows Subsystem for Linux Optional Component is installed. Additionally, if you are using an ARM64 device and running this command from PowerShell, you will receive this error. Instead run wsl.exe from PowerShell Core, or Command Prompt.

  • 1
    This was my case I didn't realized about the 32/64 jump there and when using powershell.exe I couldn't make it work so got pwsh installed using choco and then ran the wsl commands as follow pwsh.exe -NoProfile -Command 'wsl --set-default-version 2' Thanks,
    – zot24
    Commented Mar 1, 2021 at 3:59
  • 2
    This is the only sane response and should be marked as accepted, the one that is curently accepted is nothing but the quora style drivel by someone who is building their stack overflow profile.
    – aledujke
    Commented Jul 15, 2021 at 14:23
  • I'm not using an ARM64 device (I'm using AMD Ryzen) but this answer still solved my problem. The command fails in PowerShell, but it works perfectly fine in a Command Prompt. Weird.
    – Vincent
    Commented Jun 13, 2023 at 17:56

usando esse comando ele vai achar o wsl no path

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented May 17, 2023 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .