Looking around, all examples of this are written in vbscript. So I cheated and came up with this function:
static void EnableASPNET() { var file = "wmi.vbs"; using (var writer = new StreamWriter(file)) { writer.WriteLine("Set webServiceObject = GetObject(\"IIS://localhost/W3SVC\")"); writer.WriteLine("webServiceObject.EnableWebServiceExtension \"ASP.NET v2.0.50727\""); writer.WriteLine("webServiceObject.SetInfo"); } var process = Process.Start("cscript", file); process.WaitForExit(); File.Delete(file); }
source share