Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/163.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;ShellExecute批处理脚本赢得';我不能识别命令_C++_Windows_Batch File - Fatal编程技术网

C++ C++;ShellExecute批处理脚本赢得';我不能识别命令

C++ C++;ShellExecute批处理脚本赢得';我不能识别命令,c++,windows,batch-file,C++,Windows,Batch File,正如标题所示,我正试图通过“ShellExecute”函数打开一个.bat文件 它适用于非常基本的.bat脚本,如“hello world”脚本,但不适用于包含运行游戏服务器命令的其他脚本。 例如,下面是一个“Killing Floor 1”服务器的批处理脚本: 请注意,手动单击该批处理时,该批处理工作正常,但通过ShellExecute打开时会出现以下错误: "ucc" is not recognized as an internal or external command, operable

正如标题所示,我正试图通过“ShellExecute”函数打开一个.bat文件

它适用于非常基本的.bat脚本,如“hello world”脚本,但不适用于包含运行游戏服务器命令的其他脚本。 例如,下面是一个“Killing Floor 1”服务器的批处理脚本:

请注意,手动单击该批处理时,该批处理工作正常,但通过ShellExecute打开时会出现以下错误:

"ucc" is not recognized as an internal or external command, operable program or batch file.
我还测试了其他游戏服务器的其他批处理文件,得到了相同的结果

因此,下面列出了我迄今为止尝试过但没有奏效的方法:

ShellExecute(NULL, "open", "cmd.exe", "C:\\windows\\system32\\cmd.exe /C C:\\Cartella_Server\\Server_KF1\\System\\KF_Server_Launcher.bat", NULL, SW_SHOW);

ShellExecute(NULL,"open", C:\\Cartella_Server\\Server_KF1\\System\\KF_Server_Launcher.bat", NULL, NULL, SW_SHOW);

ShellExecute(NULL, "open", "cmd.exe", "/C C:\\Cartella_Server\\Server_KF1\\System\\KF_Server_Launcher.bat", NULL, SW_SHOW);
有什么解决办法吗


提前感谢您的时间:)

最有可能的是,
ucc
程序与tha启动器脚本位于同一目录中。因此,当您单击它时,它会工作,因为您的当前目录与文件是一个目录,但当您运行程序时,您的当前目录不同


解决方案-在第五个ShellExecute参数中提供正确的目录,这是因为脚本正在cmd.exe目录中加载

为什么??因为您没有填写工作目录字段

查看ShellExecute的第5个参数:

那么代码会变成什么样子呢?你能把正确的代码贴出来吗?谢谢您只需将“C:\\Cartella\u Server\\Server\u KF1\\System\\”传递到第5个参数:)
ShellExecute(NULL, "open", "cmd.exe", "C:\\windows\\system32\\cmd.exe /C C:\\Cartella_Server\\Server_KF1\\System\\KF_Server_Launcher.bat", NULL, SW_SHOW);

ShellExecute(NULL,"open", C:\\Cartella_Server\\Server_KF1\\System\\KF_Server_Launcher.bat", NULL, NULL, SW_SHOW);

ShellExecute(NULL, "open", "cmd.exe", "/C C:\\Cartella_Server\\Server_KF1\\System\\KF_Server_Launcher.bat", NULL, SW_SHOW);