Skip to content

Adding a PowerShell script to the install package (or documentation pages) to automatically enable dependency package installs #14328

@TechProofreader

Description

@TechProofreader

Is your feature request related to a problem? Please describe.
When installing WSL, the Microsoft docs state that, by simply running the standard install code wsl --install in an admin based PowerShell terminal, all dependencies will automatically be enabled and installed along with the complete WSL package. This, however, is untrue, as users, including myself, frequently run into error codes such as 0x80070424 which states that services or software required for WSL to work are not found/installed on the current system. The most common fix for this error code is to manually go into the Windows Features dashboard and manually select and enable all of the following features: "HypervisorPlatform," "VirutalMachinePlatform," and "Microsoft-Windows-Subsystem-Linux," which the WSL install frequently leaves unchecked and disabled for whatever reason(s).

Describe the solution you'd like
The workaround is clunky and prone to human error because not only can the Windows Features dashboard be cumbersome and confusing, but some packages require a system restart to actually be enabled, and this is not always apparent.

Thus, I think it may behoove Microsoft to include a PowerShell script in the WSL install or on the associated documentation pages that automatically does the above in one step. This would reduce the possibility for human error to one step instead of multiple, thereby reducing the possible dependency errors that users are currently experiencing.

I have created a draft sample of such a PowerShell script that I would need to test further before going live, but below is what I have created thus far (converting such a script to C++ to better jive with the WSL installer is also an option):

$targetFeatures = @("HypervisorPlatform", "VirutalMachinePlatform", "Microsoft-Windows-Subsystem-Linux")

foreach ($targetFeature in $targetFeatures) {
	if ($_.state -eq "Disabled") {
		Enable-WindowsOptionalFeature -Online -FeatureName "$targetFeature.ToString()" -All
	}
}

Restart-Computer -Force

Describe alternatives you've considered
One alternative, though similarly clunky to the manual enabling method within the Windows Features dashboard is to simply enable each feature one by one as follows (I recommend against this method since it adds more steps that create more chances for human error):

Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -All

Enable-WindowsOptionalFeature -Online -FeatureName "VirutalMachinePlatform" -All

Enable-WindowsOptionalFeature -Online -FeatureName "HypervisorPlatform" -All

Restart-Computer -Force

Additional context
Searching for issues with error "0x80070424" nets 360 results with 21 open and 339 closed, highlighting the importance of addressing this issue as soon as possible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions