Tag: dism

以编程方式启用IIS角色和function

我试图通过c#console应用程序启用IISfunction。 它在Windows 7和Windows 8.1机器上运行良好。 但是当我在Windows Server 2008 R2和Windows Server 2012 R2上运行相同的代码时,它无法正常工作。 我在这段代码中缺少什么? using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Management; using System.Text.RegularExpressions; namespace EnableIISComponents { class Program { static void Main(string[] args) { try { SetupIIS(); Console.WriteLine(“Done. Press any key to close.”); } catch (Exception ex) { Console.WriteLine(“Exception occurred:” + ex.Message); } Console.ReadLine(); […]