【问题标题】:How to call a batch file from visual studio 2010如何从 Visual Studio 2010 调用批处理文件
【发布时间】:2013-03-12 00:27:38
【问题描述】:

我编写了一个代码,它可以生成机翼形状并使用外部程序作为评估工具对其进行评估。我还制作了一个批处理文件,该文件启动该程序执行翼型评估所需的一些批处理命令,然后关闭程序....!!

我在每个循环中进行多次评估。我的问题是我找不到通过我的代码运行批处理文件的方法。我已经使用了下面显示的两种方法,但它们似乎都不能在 Visual Studio 2010 中工作。我用 C 编写代码,我收到 C:/Users/Angelos/Documents/CExperiments/BSplines/run.bat 不是内部的消息命令等等...!

你能检查一下并告诉我我做错了什么吗..?

谢谢

void XfoilCall()
{
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = ("C:/Users/Angelos/Documents/CExperiments/BSplines/run.bat");
ShExecInfo.lpParameters = ("");
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);


void XfoilCall()
{
system("C:/Users/Angelos/Documents/CExperiments/BSplines/run.bat");
}

【问题讨论】:

    标签: c file batch-file execute


    【解决方案1】:

    试试这个:

    system("cmd C:/Users/Angelos/Documents/CExperiments/BSplines/run.bat");
    

    【讨论】:

      【解决方案2】:

      您的斜线方向错误(它们应该是反斜线)并且需要转义。您还需要启动命令解释器 (cmd.exe) 来处理批处理脚本。

      ShExecInfo.lpFile = ("cmd.exe /c C:\\Users\\Angelos\\Documents\\CExperiments\\BSplines\\run.bat");
      

      【讨论】:

        猜你喜欢
        • 2017-05-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多