2

在 .bat 文件中包含代码 PHP filename.php 我在打开 bat 文件后收到错误消息 Could not find input file:filename.php 。任何人都可以提供建议吗

private void button5_Click_1(object sender, EventArgs e)
{
    try
    {
        string bat = "D:\\folder1\\file1.bat";
        if (File.Exists(bat))
        {
            if (radioButton1.Enabled == true)
            {
                MessageBox.Show(bat.ToString());
                System.Diagnostics.Process.Start(bat);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }
}
4

1 回答 1

5

我猜这个过程不是在与filename.php. 在 bat 文件中指定完整路径或设置启动文件夹:

Process process = new Process();
process.StartInfo.FileName = bat;
process.StartInfo.WorkingDirectory = "D:\\folder1";  // or whatever is appropriate
process.Start();
于 2013-01-25T04:21:20.627 回答