innosetup怎么调用cmd一次性运行多行命令
时间: 2024-02-01 20:03:38 浏览: 75
你可以使用以下语法在 Inno Setup 中调用 cmd 并一次性运行多行命令:
```
[Code]
function ExecCmd(CommandLine: string; Work: string; Visibility: Integer): Integer;
var
ResultCode: Integer;
OutputLines: TArrayOfString;
i: Integer;
OutputString: string;
Params: string;
cmd: string;
begin
cmd := 'cmd.exe';
Params := '/C ' + CommandLine;
Result := Exec(ExpandConstant(cmd), Params, Work, Visibility, ewWaitUntilTerminated, ResultCode);
if Result = False then
begin
MsgBox('Error executing command: ' + CommandLine, mbError, MB_OK);
end;
end;
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
begin
if CurStep = ssInstall then
begin
ExecCmd('echo command1 && echo command2 && echo command3', '', SW_HIDE);
end;
end;
```
这个例子会在安装过程的 ssInstall 步骤中调用 `ExecCmd` 函数并执行三个命令:`echo command1`、`echo command2` 和 `echo command3`。这些命令会在 cmd 中一次性运行,并且隐藏 cmd 窗口。
阅读全文