Search code examples
c#.netwindowscontrolpanel

How can you programmatically turn off or on 'Windows Features'


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.

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


Solution

  • I do this using NSIS for IIS using :

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

    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.

    You need to use

     System.Diagnostics.Process.Start().