I'm trying to add an application start task to unlock the ipSecurity section of the ApplicationHost.config file in my project. I have an cmd file located in /startup/startup.cmd. This is the contents of the file:
@echo off
@echo Installing "IPv4 Address and Domain Restrictions" feature
powershell -ExecutionPolicy Unrestricted -command "Install-WindowsFeature Web-IP-Security"
@echo Unlocking configuration for "IPv4 Address and Domain Restrictions" feature
%windir%\system32\inetsrv\AppCmd.exe unlock config -section:system.webServer/security/ipSecurity
I've added this to application_start in Global.asax to run it:
var rootPath = HostingEnvironment.ApplicationPhysicalPath;
var startupFilePath = String.Format("{0}startup\\startup.cmd", rootPath);
System.Diagnostics.Process.Start(startupFilePath);
When I tried to load my site I got the error The specified executable is not a valid application for this OS platform
. How do I resolve this?