我的批处理文件要求输入y / n。 我使用CreateProcess()方法运行该批处理文件。 如果我使用/ y作为commnad行运行我的批处理文件,它不会要求输入。 例如
run.bat /y我想用命令行/ y使用CreateProcess()运行我的批处理文件,如上所述,例如,我不知道如何使用CreateProcess()来执行此操作,我不想修改我的批处理文件。
::CreateProcess(L"run.bat",NULL,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startInfo,&procInfo ) ,我也试试这个
::CreateProcess(L"run.bat",L"/y",NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startInfo,&procInfo )
但是,它不起作用。 如果有人知道怎么做,请告诉我。
:: CreateProcess(L“run.bat”,L“/ y”,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startInfo,&procInfo)这很好用。 这是我的错误,我改变了如果部分和我的流程进入其他部分。 我总是改变我的if部分。 谢谢你的快速回复。
my batch file asking for input y/n. i run that batch file using CreateProcess() method. If i run my batch file with /y as commnad line, it not ask for input. e.g
run.bat /yi want to run my batch file using CreateProcess() with command line /y,as above e.g, i don't know how to do this using CreateProcess() an i don't want to modify my batch file.
::CreateProcess(L"run.bat",NULL,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startInfo,&procInfo ) , i also try this
::CreateProcess(L"run.bat",L"/y",NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startInfo,&procInfo )
but,it not works. If anyone know how to do this,plz let me know.
::CreateProcess(L"run.bat",L"/y",NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startInfo,&procInfo ) this works fine. it's my mistake i change in if part and my flow goes in else part. and i always change in my if part. thanks for quick reply.
最满意答案
尝试这个
::CreateProcess(L"cmd.exe", L"/c run.bat /y", NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &startInfo, &procInfo )正如它在MSDN上所说的那样
要运行批处理文件,必须启动命令解释程序; 将lpApplicationName设置为cmd.exe并将lpCommandLine设置为以下参数:/ c加上批处理文件的名称。
Try this
::CreateProcess(L"cmd.exe", L"/c run.bat /y", NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &startInfo, &procInfo )As it says on MSDN
To run a batch file, you must start the command interpreter; set lpApplicationName to cmd.exe and set lpCommandLine to the following arguments: /c plus the name of the batch file.
更多推荐
发布评论