Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 通过CMD、asp.NET MVC 4执行.bat文件_Asp.net Mvc_Windows_Batch File_Cmd - Fatal编程技术网

Asp.net mvc 通过CMD、asp.NET MVC 4执行.bat文件

Asp.net mvc 通过CMD、asp.NET MVC 4执行.bat文件,asp.net-mvc,windows,batch-file,cmd,Asp.net Mvc,Windows,Batch File,Cmd,我想在发布这些文件的IIS服务器上通过CMD执行.bat文件。我将批处理文件放在解决方案的App_Data目录中,并将其设置为“始终复制”,以便从部署中将其保存在IIS上 我也有一个网站。cshtml,如果我调用这个网站,它应该继续与批处理文件的cmd。我使用以下代码完成了此操作: string filePath = HttpContext.Current.Server.MapPath("~/App_data/Auto_Deploy_" + branch + ".b

我想在发布这些文件的IIS服务器上通过CMD执行.bat文件。我将批处理文件放在解决方案的App_Data目录中,并将其设置为“始终复制”,以便从部署中将其保存在IIS上

我也有一个网站。cshtml,如果我调用这个网站,它应该继续与批处理文件的cmd。我使用以下代码完成了此操作:

string filePath = HttpContext.Current.Server.MapPath("~/App_data/Auto_Deploy_" + branch + ".bat");
        ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd.exe", "/c " + filePath);
        procStartInfo.WorkingDirectory = "C:\\";
        procStartInfo.RedirectStandardOutput = true;
        procStartInfo.UseShellExecute = false;
        procStartInfo.CreateNoWindow = false;
        procStartInfo.RedirectStandardError = true;
if (Environment.OSVersion.Version.Major >= 6)
        {
            procStartInfo.Verb = "runas";
        }

        procStartInfo.FileName = "cmd.exe";
我从以下几点开始行动:

Process proc = new Process();
        proc.StartInfo = processStartInfo;
        proc.Start();
        proc.WaitForExit();
我还生成了一个app.manifest并编辑了该行

<requestedExecutionLevel>

因为我认为,应该使用管理员权限

如果我从服务器上的localhost连接到网站,我将指向该网页,该脚本将运行,并在屏幕上发布输出和错误

我总是遇到同样的错误:

Das系统不适合使用

系统找不到路径


你能告诉我问题出在哪里吗?

谢谢你的帮助,我现在确实写了一个小的windows服务,谁在做这项工作。

这听起来像是一个可怕的黑客攻击,你确定运行批处理文件是完成你需要的任务的唯一方法吗?@DavidG:谢谢你的快速响应。问题是,我们有一个GIT存储库,并希望执行一个自行创建的自动部署。我们在另一台服务器上向GIT repo提交了一些内容。Git Repo向我创建的这个ASP.NET站点发送一个带有GET参数的简单webhook。此站点现在应该运行批处理文件,该文件删除服务器上的旧repo本地,下载新repo,构建并部署到IIS。那么您希望您的网站部署您的网站吗?听起来有点像《盗梦空间》:@大卫,对不起,我现在编辑了我的答案。我们正在使用此批处理文件为其他网站执行自动部署。我建议您使用部署工具来执行此操作。我以前使用过它,它允许我使用git推送从命令行直接部署我的网站。或者,像这样的商业产品也令人惊叹。
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />