WSL: Cannot start Windows executable from powershell.exe started from WSL2 after wsl.exe --update

Version

Windows version: 10.0.19044.2364

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.79.1

Distro Version

Ubuntu 20.04

Other Software

n/a

Repro Steps

$ powershell.exe

PS C:\temp> dir \\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey\AutoHotkeyU64.exe



    Directory: \\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
------        12/21/2020   2:56 AM        1190400 AutoHotkeyU64.exe


PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey> .\AutoHotkeyU64.exe

Program 'AutoHotkeyU64.exe' failed to run: Incorrect functionAt line:1 char:1
+ .\AutoHotkeyU64.exe
+ ~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ .\AutoHotkeyU64.exe
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed
$ cmd.exe

C:\temp>dir \\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey\AutoHotkeyU64.exe
 Volume in drive \\wsl.localhost\Ubuntu-20.04 has no label.
 Volume Serial Number is 0000-0000

 Directory of \\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey

21/12/2020  02:56         1.190.400 AutoHotkeyU64.exe
               1 File(s)      1.190.400 bytes
               0 Dir(s)  170.607.165.440 bytes free

C:\temp>\\wsl.localhost\Ubuntu-20.04\home\d057039\dotfiles\assets\AutoHotkey\AutoHotkeyU64.exe
The system cannot execute the specified program.

It is also impossible to open file associated with the executable:

d057039:AutoHotkey|master$ cmd.exe /c start FixCtrlBackspace.ahk
The system cannot execute the specified program.

Expected Behavior

Executing Windows programs on WSL2 paths from cmd.exe or powershell.exe is possible if the latter it started from WSL2 environment (in current example AutoHotkeyU64.exe starts.

Actual Behavior

cmd.exe: The system cannot execute the specified program. powershell.exe: NativeCommandFailed

Diagnostic Logs

Remarks:

  1. Before the wsl.exe --update cmd.exe and poweshell.exe could start executables on WSL2 paths just same fine as other executables.
  2. WSL2 start Windows executable correctly.
  3. cmd.exe or powershell.exe which are started natively from Windows also start any executable on WSL2 path perfectly.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 16 (1 by maintainers)

Most upvoted comments

I also have this issue. I think it may be related to the switch to the Microsoft Store version of WSL

I am seeing a similar issue, where we use a windows python.exe from WSL, and after wsl --update, processes started from within python.exe fail to run (WindowsError: [Error 1] Incorrect function). The same python script, run in the same python.exe, but started from within windows, does not fail. Also, running the process directly from WSL (not via python) also works. Seems like exactly the same issue, but with python instead of cmd.exe or powershell.exe.

Since my issue is very similar but slightly different (Python instead of cmd or powershell) I have raised another issue. Can I link them? https://github.com/microsoft/WSL/issues/9370