win10调用wsl执行linux命令,如何从WSL(Ubuntu)Bash运行Windows可执行文件

问题描述

随着2016年夏季的Windows 10周年更新,可以在新的Windows Subsystem for Linux (WSL)(“lightweight”虚拟化子系统)中运行ubuntu二进制文件。

不幸的是,启动C:\Windows\System32\bash.exe,另一个bash ELF二进制文件启动了WSL内部的进程,从那里你无法逃脱!您可以只启动其他ELF二进制文件。

那么如何从Windows Bash执行*.exe文件?[1]

最佳解决方法

原生解决方案

Windows 10 Insider预览更新(14951)提供的官方解决方案基于几乎被遗忘的用于启动二进制文件的binfmt_msc Linux工具。 binfmt_misc的注册命令是这样的(其中/init是win-executables的临时binfmt_misc “interpreter”):

sudo echo ":WSLInterop:M::MZ::/init:" > /proc/sys/fs/binfmt_misc/register

然后win-executable将像常规程序一样启动:

$ export PATH=$PATH:/mnt/c/Windows/System32

$ notepad.exe

$ ipconfig.exe | grep IPv4 | cut -d: -f2

$ ls -la | findstr.exe foo.txt

$ cmd.exe /c dir

Not that any win-executable must reside in the windows (DrvFs) file-system – not on the Linux’s file-system (VolFs) – in order

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值