Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Winsock module breaks WSL2 #40

Closed
wtto00 opened this issue Feb 22, 2023 · 0 comments
Closed

Winsock module breaks WSL2 #40

wtto00 opened this issue Feb 22, 2023 · 0 comments

Comments

@wtto00
Copy link
Owner

wtto00 commented Feb 22, 2023

issues #4177

如果应用商店安装了Windows Subsystem for Linux

  1. 首先找到安装位置,最简单的方法是,打开应用商店,找到应用Windows Subsystem for Linux,点击应用详细介绍页面的打开按钮,会新打开一个 terminal 窗口,窗口的标题上面有所安装的wsl.exe的全路径。

    或者也可以手动搜索,由于目录C:\Program Files\WindowsApps是保护文件夹,没法直接在资源管理器中搜索,可以管理员打开powershell

    cd "C:\Program Files\WindowsApps"
    ls

    找到对应版本的 wsl 目录,例如MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe

  2. 下载nolsp.exe

  3. 管理员打开powershell,执行以下命令:

    # 打开nolsp.exe所在目录
    cd E:\Downloads\Other\nolsp.exe
    
    # 该步骤就相当于添加注册表
    .\nolsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wsl.exe"
    .\nolsp.exe "C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wslservice.exe"
    # 注意:这里的wsl.exe以及wslservice.exe,必须是全路径,不能是相对路径。

    打开注册表regedit,找到\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog,依次点击此目录的各项,可以找到两项:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\2BB0D7FB]
    "AppFullPath"="C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wsl.exe"
    "PermittedLspCategories"=dword:80000000
    
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\2FB92E99]
    "AppFullPath"="C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.1.2.0_x64__8wekyb3d8bbwe\wslservice.exe"
    "PermittedLspCategories"=dword:80000000
    

至此,就可以打开 wsl 了。
如果商店更新了Windows Subsystem for Linux,需要重新执行一遍此流程


如果应用商店没有安装Windows Subsystem for Linux

直接在注册表regedit添加项即可:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\Windows\System32\wsl.exe"
"PermittedLspCategories"=dword:80000000

临时解决办法:

管理员打开 powershell,运行netsh winsock reset,不用重启,就可以打开 wsl 了。
但是每次重新启动电脑时,都要重新运行一次此流程。

@wtto00 wtto00 added the WSL label Feb 22, 2023
@wtto00 wtto00 closed this as completed Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant