簡體   English   中英

我想在C#asp.net(mvc)中運行.exe或bat文件

[英]I want to run .exe or bat file in C# asp.net (mvc)

以下是我使用過的不同代碼,但我需要執行ETL或批處理文件,並通過查看頁面鏈接到了按鈕dashbord,但是我無法執行或運行文件,請在同一位置建議我

public ActionResult RunETL(){
    try
    {
        System.Diagnostics.Process p = new System.Diagnostics.Process();
        p.StartInfo = new System.Diagnostics.ProcessStartInfo(@"D:\Jobs\Execute");
        p.Start();


        //Process p = new Process();
        //// Redirect the output stream of the child process.
        //p.StartInfo.UseShellExecute = false;
        //p.StartInfo.RedirectStandardOutput = true;
        ////p.StartInfo.FileName = @"D:\Jobs\Execute";

        //p.Start();
        //// Do not wait for the child process to exit before
        //// reading to the end of its redirected stream.
        //p.WaitForExit();
        //// Read the output stream first and then wait.
        //string output = p.StandardOutput.ReadToEnd();
        //p.WaitForExit();
        //Response.Write("Done");
        ////ViewBag.Result = "ETL Running";
    }
    catch (Exception ex)
    {

        //ViewBag.Result = ex.Message;

    }

    return RedirectToAction("Home");
}

查看用於運行Web應用程序的應用程序池標識。

它應該在批處理文件的位置具有執行權。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM