你怎么能编程方式打开或关闭“Windows功能”你怎么、方式、功能、Windows

2023-09-05 01:18:50 作者:痞子绅士

目前,用户必须进入控制面板>程序> Windows功能打开或关闭,然后点击检查,他们想激活该功能的框。我想给他们从我的应用程序做到这一点的能力。

Currently, users must go into Control Panel > Programs > Turn Windows features on or off, then click on the check the box of the feature that they want to activate. I'd like to give them the ability to do this from my application.

如何通过.NET(preferably在C#中)?

Any idea on how to automate this process via .NET (preferably in C#)?

推荐答案

我这样做是利用NSIS为IIS使用:

I do this using NSIS for IIS using :

$Sysdir\pkgmgr.exe /n:$Temp\iis7Unattend.xml

您可以从C#程序调用PKGMGR程序,通常你会创建一个无人参与文件的说明为PKGMGR使用该功能。

You can call the pkgmgr program from your c# program and usually you would create an unattend file with the instructions for the pkgmgr to use for the feature.

您需要使用

 System.Diagnostics.Process.Start().
 
精彩推荐
图片推荐