2023-05-02 2026-01-25 任务管理器关闭wslservice.exe,wslg.exe等然后管理员打开powershell运行以下代码 123456789101112131415161718192021222324#Requires -RunAsAdministrator# Fix for https://github.com/microsoft/WSL/issues/4177$MethodDefinition = @'[DllImport("ws2_32.dll", CharSet = CharSet.Unicode)]public static extern int WSCSetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, uint PermittedLspCategories, out uint pPrevPermLspCat, out int lpErrno);'@$Ws2Spi = Add-Type -MemberDefinition $MethodDefinition -Name 'Ws2Spi' -PassThru$WslLocation = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemForLinux | Select-Object -expand InstallLocation$Executables = ("wsl.exe", "wslservice.exe","wslg.exe","wslhost.exe");foreach ($Exe in $Executables) { $ExePath = "${WslLocation}\${Exe}"; $ExePathLength = $ExePath.Length; $PrevCat = $null; $ErrNo = $null; if ($Ws2Spi::WSCSetApplicationCategory($ExePath, $ExePathLength, $null, 0, [uint32]"0x80000000", [ref] $PrevCat, [ref] $ErrNo) -eq 0) { Write-Output "Added $ExePath!"; }} 把以上脚本设置为开机启动,这样windows store更新wsl的时候也能同步更新。参考:https://github.com/microsoft/WSL/issues/4177#issuecomment-1359200646 前一篇 如何导出windows平台下cloudflare warp内部存的私钥和token 后一篇 Word合并表格回车删除不掉的解决方法
说些什么吧!