Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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#)?

like image 334
ymerej Avatar asked Feb 03 '23 12:02

ymerej


1 Answers

If you are only targeting newer platforms (>= Windows Vista) then dism.exe is the latest utility; it replaces pkgmgr.

  1. http://technet.microsoft.com/en-us/library/dd799309(WS.10).aspx
  2. http://msdn.microsoft.com/en-us/library/dd371719(v=vs.85).aspx

Example call (run for all required features):

dism.exe /online /enable-feature /featurename:IIS-WebServerRole

To find a feature, use this

dism.exe /online /get-features | find “Tablet”

see: http://adriank.org/microsoft-ocsetupdism-component-name-list/ for more info.

like image 55
thebitguru Avatar answered Feb 05 '23 03:02

thebitguru