Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding features in Windows 2008 Server R2 in Server Manager programmatically

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.

like image 588
ServerManagerInEnthusiast Avatar asked Jun 01 '26 13:06

ServerManagerInEnthusiast


2 Answers

This can be done by invoking the dism command programmatically:

dism /Online /Enable-Feature:NetFx3

I would be interested in hearing any solutions that don't require a shell-out though.

like image 149
bdonlan Avatar answered Jun 04 '26 12:06

bdonlan


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 these PowerShell Cmdlets

  • Add-WindowsFeature
  • Get-WindowsFeature
  • Remove-WindowsFeature
like image 39
RRUZ Avatar answered Jun 04 '26 11:06

RRUZ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!