Running a batch file from an ASP.Net page

后端 未结 2 1465
粉色の甜心
粉色の甜心 2021-01-12 12:17

I\'m trying to run a batch file on a server via an ASP.Net page, and it\'s driving my crazy. When I run the below code, nothing happnes - I can see from some log statements

相关标签:
2条回答
  • 2021-01-12 13:02

    Just call the batch file directly:

    p.StartInfo.FileName = batchFileLocation;
    

    Also, make sure the WorkingDirectory is set to the right location:

    p.StartInfo.WorkingDirectory= Path.GetDirectoryName(batchFileLocation);
    
    0 讨论(0)
  • 2021-01-12 13:18

    A little google on "Faulting application cmd.exe" points me to this IIS forum.

    It seems that you cannot create a new process in the background under IIS, unless you use the CreateProcessWithLogon method. (I have not tested this).

    0 讨论(0)
提交回复
热议问题