I tried to replicate this and run into this problem immediately. After (quite) a bit of confusion, I found this link and realized my test project was targeting x86 instead of x64 . Duh ...
wsl.exe
and bash.exe
are 64-bit files, stored in c:\Windows\System32
. If you try running them from an x86 application they appear to be missing. That's because Windows shows a different, 32-bit specific c:\Windows\System32
folder to 32-bit applications. The 64-bit System32 folder will appear under C:\Windows\Sysnative
.
The easy solution is to change the target to x64. Once that's done, even
system("wsl ls -la");
or
system("bash -c ls -la");
Just work.
For x86 applications the solution is to use the absolute path in Sysnative
, eg :
system("c:/windows/sysnative/bash -c ls -la");
or
system("c:/windows/sysnative/wsl -c ls -la");
del
command?wsl.exe
(like in a Windows prompt) but you probably need to know more about Windows than I do to get that working...wsl.exe
paths are set, right?wsl args...
orcmd wsl arg...
?