【发布时间】:2017-04-28 13:17:01
【问题描述】:
我到处寻找这个答案。这是在调试期间单击网页上的 button1 时的情况。我尝试了几个目录,但都没有运气。有什么建议么。我绝对肯定这不是路径名的问题。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
public partial class Simulators : System.Web.UI.Page
{
private System.Diagnostics.Process myBatProcess;
//private void Form1_Load(object sender, EventArgs e)
//{
// this.button1.Click += new EventHandler(button1_Click);
//}
public void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.ProcessStartInfo myBatStartInfo = new
System.Diagnostics.ProcessStartInfo();
myBatStartInfo.UseShellExecute = true; // needed since bat is not an executable
myBatStartInfo.FileName = @"C:\BATs\TrainingProZ_10_EC_autoscale.bat";
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
public partial class Simulators : System.Web.UI.Page
{
private System.Diagnostics.Process myBatProcess;
//private void Form1_Load(object sender, EventArgs e)
//{
// this.button1.Click += new EventHandler(button1_Click);
//}
public void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.ProcessStartInfo myBatStartInfo = new System.Diagnostics.ProcessStartInfo();
myBatStartInfo.UseShellExecute = true; // needed since bat is not an executable
myBatStartInfo.FileName = @"C:\Users\175020\Desktop\ProZ_10_EC_autoscale.bat";
myBatProcess = System.Diagnostics.Process.Start(myBatStartInfo);
}
protected void Button2_Click(object sender, EventArgs e)
{
}
}
myBatProcess = System.Diagnostics.Process.Start(myBatStartInfo);
}
protected void Button2_Click(object sender, EventArgs e)
{
}
}
【问题讨论】:
-
您是否尝试使用 myBatStartInfo.WorkingDirectory = @"C:\BATs" 然后只使用 myBatStartInfo.FileName="TrainingProZ_10_EC_autoscale.bat" 设置工作目录?