从ASP.NET应用程序池标识运行命令

dan*_*iel 7 c# asp.net iis-7 application-pool applicationpoolidentity

当用户单击按钮时,我正在从ASP.NET应用程序运行可执行进程.此过程会创建多个文件,并将其提供给最终用户.我无法确切地看到进程是做什么或不做什么,但是直到我将admin用户指定为服务器上的应用程序池标识才行.我正在使用IIS7.

 using (var proc = new Process())
 {
    proc.StartInfo.FileName = Server.MapPath("~/Testing/Demo/MyExe.exe");
    proc.StartInfo.Arguments = String.Format("\"{0}\"", commandFilePath);
    proc.StartInfo.UseShellExecute = true;
    proc.Start();
    proc.WaitForExit();
 }
Run Code Online (Sandbox Code Playgroud)

我认为这通常是一件坏事.您能否让我深入了解为正常ApplicationPoolIdentity帐户启用此功能需要做些什么?

谢谢!

dan*_*iel 1

感谢大家的帮助。我所需要做的就是将 StartInfo.WorkingDirectory 设置为我能够写入的位置。

        using (var proc = new Process())
        {
            proc.StartInfo.FileName = Server.MapPath("~/Testing/Demo/MyEXE.exe");
            proc.StartInfo.Arguments = String.Format("\"{0}\"", commandFile);
            proc.StartInfo.WorkingDirectory = savePath;
            proc.Start();
            proc.WaitForExit();
        }
Run Code Online (Sandbox Code Playgroud)

这会导致临时文件写入非系统文件夹,因此不需要应用程序池的任何提升权限。