diff --git a/localization/strings/en-US/Resources.resw b/localization/strings/en-US/Resources.resw
index 55a700b83..1a9b8cbd8 100644
--- a/localization/strings/en-US/Resources.resw
+++ b/localization/strings/en-US/Resources.resw
@@ -960,6 +960,10 @@ Falling back to NAT networking.
Update failed (exit code: {}).
{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated
+
+ {} does not take any arguments. To unregister a distribution, use {} instead.
+ {FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated
+
Uninstall failed (exit code: {}).
{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated
diff --git a/src/windows/common/WslClient.cpp b/src/windows/common/WslClient.cpp
index 49cdb5ef7..e1f3a0f1f 100644
--- a/src/windows/common/WslClient.cpp
+++ b/src/windows/common/WslClient.cpp
@@ -1751,6 +1751,15 @@ int WslMain(_In_ std::wstring_view commandLine)
}
else if (argument == WSL_UNINSTALL_ARG)
{
+ commandLine = wsl::windows::common::helpers::ConsumeArgument(commandLine, argument);
+ argument = wsl::windows::common::helpers::ParseArgument(commandLine);
+ if (!argument.empty())
+ {
+ wsl::windows::common::wslutil::PrintMessage(
+ Localization::MessageUninstallNoArguments(WSL_UNINSTALL_ARG, WSL_UNREGISTER_ARG), stdout);
+ return exitCode;
+ }
+
return Uninstall();
}
else
diff --git a/test/windows/UnitTests.cpp b/test/windows/UnitTests.cpp
index f97e96455..0b84655fe 100644
--- a/test/windows/UnitTests.cpp
+++ b/test/windows/UnitTests.cpp
@@ -6562,5 +6562,13 @@ Error code: Wsl/InstallDistro/WSL_E_INVALID_JSON\r\n",
VERIFY_ARE_EQUAL(result.ExitCode, 0);
}
+ TEST_METHOD(UninstallRejectsArguments)
+ {
+ VerifyOutput(
+ L"--uninstall Distro",
+ wsl::shared::Localization::MessageUninstallNoArguments(WSL_UNINSTALL_ARG, WSL_UNREGISTER_ARG) + L"\r\n",
+ -1);
+ }
+
}; // namespace UnitTests
} // namespace UnitTests