Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.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
Batch file 使用ShellExecuteEx从Inno安装程序中的批处理文件中获取退出代码_Batch File_Inno Setup_Exit Code_Shellexecuteex - Fatal编程技术网

Batch file 使用ShellExecuteEx从Inno安装程序中的批处理文件中获取退出代码

Batch file 使用ShellExecuteEx从Inno安装程序中的批处理文件中获取退出代码,batch-file,inno-setup,exit-code,shellexecuteex,Batch File,Inno Setup,Exit Code,Shellexecuteex,我有几个从Inno安装程序执行的批处理文件。我使用ShellExecuteEx()执行批处理文件: 函数ShellExecuteWait(常量动词、文件名、参数、工作目录:字符串;常量ShowCmd:integer;常量超时:基数;变量ExitCode:DWORD):布尔值; 变量 ExecInfo:TShellExecuteInfo; 开始 结果:=假; ExecInfo.cbSize:=SizeOf(ExecInfo); ExecInfo.fMask:=请参阅屏蔽过程; ExecInfo.W

我有几个从Inno安装程序执行的批处理文件。我使用
ShellExecuteEx()
执行批处理文件:

函数ShellExecuteWait(常量动词、文件名、参数、工作目录:字符串;常量ShowCmd:integer;常量超时:基数;变量ExitCode:DWORD):布尔值;
变量
ExecInfo:TShellExecuteInfo;
开始
结果:=假;
ExecInfo.cbSize:=SizeOf(ExecInfo);
ExecInfo.fMask:=请参阅屏蔽过程;
ExecInfo.Wnd:=0;
ExecInfo.lpVerb:=动词;
ExecInfo.lpFile:=文件名;
ExecInfo.lpParameters:=参数;
ExecInfo.lpDirectory:=WorkingDir;
ExecInfo.nShow:=ShowCmd;
如果ShellExecuteEx(ExecInfo),则
开始
如果WaitForSingleObject(ExecInfo.hProcess,Timeout)=等待\u超时,则
开始
TerminateProcess(ExecInfo.hProcess,等待超时);
结束,否则开始
结束;
GetExitCode进程(ExecInfo.hProcess,ExitCode);
结果:=(ExitCode=ERROR\u SUCCESS);
结束,否则开始
ExitCode:=GetLastError();
结束;
结束;
如果(不是ShellExecuteWait(“”,
指挥部,
Params,
ExpandConstant({tmp}'),
SW_秀,
超时,
结果代码)然后。。。
但是无论我尝试什么,我都无法从
ResultCode
中的批处理文件中获取退出代码(我总是返回0)

在研究这个问题时,我读到批处理不能使用
exit/b NN
。因此,我删除了
/b
开关,但始终得到0

要从批处理文件中成功获取退出代码,我必须做什么


丹尼斯我发现了这个问题。调用批处理文件的命令包括通过另一个程序的管道,因此我得到的结果代码实际上来自通过管道传输脚本输出的程序。

我发现了问题。调用批处理文件的命令包括通过另一个程序的管道,因此我得到的结果代码实际上来自通过管道传输脚本输出的程序。

您使用
ShellExecuteEx
而不是plain的原因是什么?您使用
ShellExecuteEx而不是plain的原因是什么?