How do I turn a Windows feature on/off from the command line in Windows 10? [closed]

我们两清 提交于 2019-12-05 14:53:56

问题


In Windows 10 and from "Programs and Features", you can turn Windows features on or off and then initiate a download and installation. I wish to turn ".NET Framework 3.5" ON and have it downloaded and installed, but I need to do it via e.g. a PowerShell script or via a command. I need to use the command line.

How can this be achieved?


回答1:


Run a command prompt as an administrator and use:

dism /online /Get-Features

This will display the feature names since they don't always match up with what you're seeing in that visual feature list. It will also show which are currently enabled/disabled. Once you find the feature that you'd like to enable (NetFx3 in this case), run this:

dism /online /Enable-Feature /FeatureName:NetFx3

And as Richard stated, you can then disable a feature by simply switching "Enable" to "Disable" ex.

dism /online /Disable-Feature /FeatureName:NetFx3

Note: Sometimes a restart is required to see changes with windows features.




回答2:


To enable and disable features on a client machine of Windows using PowerShell, the cmdlet you have to use is:

Enable-WindowsOptionalFeature

For example, with Windows 10 and NetFX 3, I would check if the feature is enabled with

Get-WindowsOptionalFeature -Online | where featurename -Like "netfx3"

If not enabled, run this to enable it:

Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -Source "SourcePath"



回答3:


I'm not sure how you would go about kicking off a download, but you can get the files from the Windows 10 install CD/ISO. Copy the folder called 'D:\sources\sxs' and store these file somewhere.

Once you have the files you can install them with the following command, run it with administrative rights. Make sure you change the /Source: parameter to the location you copied 'sxs' folder to.

DISM /online /enable-feature /featurename:NetFx3 /All /Source:D:\sources\sxs /LimitAccess

If you wish to unstill the feature by command line you can use the following comamnd.

DISM /online /disable-feature /FeatureName:NetFx3


来源:https://stackoverflow.com/questions/35479080/how-do-i-turn-a-windows-feature-on-off-from-the-command-line-in-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!