我有一个我从命令行调用的exe。是否可以在服务器上执行该文件?在计算机上如果文件位于文件夹abc中,我转到文件夹abc而不是执行批处理。我是否在C#
中这样做答案 0 :(得分:5)
下面的代码示例,请确保您正确设置了权限:
System.Diagnostics.Process yourProcess = new System.Diagnostics.Process();
// Set the directory
yourProcess.StartInfo.WorkingDirectory = Request.MapPath("~/"); //or wherever your file is
// Set the filename
yourProcess.StartInfo.FileName = Request.MapPath("bla.exe");
// Start the process
yourProcess.Start();
答案 1 :(得分:0)
在服务器端代码当然,Process.Start(MyExeFile)会这样做,但是,只要你运行你的东西的用户帐户可以执行它。