如何从 Windows 10 的命令行打开/关闭 Windows 功能? [英] How do I turn a Windows feature on/off from the command line in Windows 10?

查看:38
本文介绍了如何从 Windows 10 的命令行打开/关闭 Windows 功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 10 和程序和功能"中,您可以打开或关闭 Windows 功能,然后开始下载和安装.我希望打开.NET Framework 3.5"并下载并安装它,但我需要通过例如PowerShell 脚本或通过命令.我需要使用命令行.

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.

如何实现?

推荐答案

以管理员身份运行命令提示符并使用:

Run a command prompt as an administrator and use:

dism /online /Get-Features

这将显示功能名称,因为它们并不总是与您在该可视功能列表中看到的内容相匹配.它还将显示当前启用/禁用的内容.找到要启用的功能(在本例中为 NetFx3)后,运行以下命令:

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

正如 Richard 所说,您可以通过简单地将启用"切换为禁用"来禁用某个功能.

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

dism /online /Disable-Feature /FeatureName:NetFx3

注意:有时需要重新启动才能查看 Windows 功能的更改.

这篇关于如何从 Windows 10 的命令行打开/关闭 Windows 功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆