以编程方式在服务器管理器中添加 Windows 2008 Server R2 中的功能
我正在编写一个需要.NET 才能运行的程序。 当我在 Windows 2008 Server R2 上运行它时,它在安装 .NET 3.5 时失败。 这是因为在此版本的 Windows 中,您只能通过服务器管理器(或角色管理器)安装 .NET 3.5。
我想知道是否有办法以编程方式做到这一点?
我在网上搜索了一下,发现也许我可以使用 PowerShell 或 WMI。我希望这里有人可以验证这是否是正确的方法,如果不是,请为我指出正确的方向。
更新:
通过进一步调查,我发现使用 WMI Win32_ServerFeature_ID 类我可以枚举现有功能。但我找不到任何关于如何添加新功能的解释。
非常需要帮助。
谢谢。
I am writing a program that needs .NET to run.
When I run it on Windows 2008 Server R2 it fails upon .NET 3.5 installation.
This is because in this version of Windows you can only install .NET 3.5 via Server Manager (or Role Manager).
I was wondering if there is a way to do it programmatically?
I searched the web and found that maybe I could use PowerShell or WMI. I hoped that someone here could verify that that's the way to go, and if not, point me in the right direction.
UPDATE:
From further investigation I found that using WMIs Win32_ServerFeature_ID class I can enumerate the existing features. But I cannot find any explanation as to how to add a new feature.
Help very much needed.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可以通过以编程方式调用
dism
命令来完成:我有兴趣听到任何不需要 shell-out 的解决方案。
This can be done by invoking the
dism
command programmatically:I would be interested in hearing any solutions that don't require a shell-out though.
Win32_ServerFeature
wmi 类不公开任何添加或删除 Windows 服务器功能的方法,仅用于列出已安装的功能。据我所知,没有 WMI 类来执行此任务。我可以推荐您的选项是使用这些PowerShell Cmdlet
The
Win32_ServerFeature
wmi class does not expose any method to add or remove a Windows server feature, only is intended for list the features installed. and as far I know there is not a WMI class to do this task. the option which I can recomend you is use thesePowerShell Cmdlets
我知道这个回复是针对 Windows 7 的,但对于任何寻找的人来说,有一个适用于 Windows 7 的扩展。 PowerShell 模块添加/删除 Windows 7 功能
I know this reply is in reference to Windows 7, but for anyone looking, there is an extension that works for Windows 7. PowerShell module to Add/Remove Windows 7 features
我们使用 PowerShell 来自动化服务器设置,您会发现它可以很好地完成您喜欢的事情。对于您正在查看的功能,脚本将如下所示:
此脚本将可以通过应用程序的安装过程运行......可能。我已经从 Windows Installer 自定义操作运行 PowerShell,这是(根据我的经验)最困难的情况。
We use PowerShell to automate server setup, you'll find it will do what you like very nicely. For the feature you're looking at the script would look something like this:
This script will be runnable via your application's installation process... probably. I've run PowerShell from Windows Installer custom actions and that's (in my experience) the toughest case.