0

我正在尝试添加一个应用程序启动任务来解锁我项目中 ApplicationHost.config 文件的 ipSecurity 部分。我有一个位于 /startup/startup.cmd 的 cmd 文件。这是文件的内容:

@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

我已将此添加到 Global.asax 中的 application_start 以运行它:

var rootPath = HostingEnvironment.ApplicationPhysicalPath;
var startupFilePath = String.Format("{0}startup\\startup.cmd", rootPath);
System.Diagnostics.Process.Start(startupFilePath);

当我试图加载我的网站时,我得到了错误The specified executable is not a valid application for this OS platform。我该如何解决这个问题?

4

0 回答 0