Created
February 6, 2026 13:48
-
-
Save h-mochizuki/f0a40e027792dc003e2a4257dccf2dbf to your computer and use it in GitHub Desktop.
WSL2のUbuntuを再インストールするバッチファイル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal | |
| set PSFILE=%TEMP%\embedded_admin.ps1 | |
| > "%PSFILE%" ( | |
| echo Write-Host "PowerShell admin mode" | |
| echo Write-Host "Checking installed WSL distributions..." | |
| echo wsl -l -v ^| findstr ^/C:"Ubuntu" | |
| echo Write-Host "Shutting down WSL..." | |
| echo wsl --shutdown | |
| echo Write-Host "Unregistering Ubuntu distribution..." | |
| echo wsl --unregister Ubuntu | |
| echo Write-Host "Reinstalling Ubuntu distribution..." | |
| echo wsl --install -d Ubuntu | |
| ) | |
| powershell -NoProfile -ExecutionPolicy Bypass -Command ^ | |
| "Start-Process powershell -Verb RunAs -ArgumentList '-NoProfile -ExecutionPolicy Bypass -NoExit -File \"%PSFILE%\"'" | |
| endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment