Inno Setup:如何以编程方式 运行 已安装的批处理文件
Inno Setup: How to run an installed batch file programmatically
如何在 Code
部分(程序 DeinitializeSetup
)中 运行 一个 bat
文件?
正如我尝试做的:
Exec('"' + installationFolder + '\mysql\db\db.cmd"',
'"'+ installationFolder +'"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
源和目标参数返回到正确的位置。
要执行批处理文件,请使用 Exec
support function。
Exec()
的 Filename
参数中不应有引号。
procedure DeinitializeSetup();
var
InstallationFolder: string;
ResultCode: Integer;
begin
InstallationFolder := ExpandConstant('{app}');
if Exec(InstallationFolder + '\mysql\db\test.bat',
'"' + InstallationFolder + '"',
'', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
Log('Succeeded running batch file');
end
else
begin
Log('Failed running batch file');
end;
end;
如果我安装 test.bat
包含以下内容:
@echo off
echo This is test
echo The provided installation path is %1
echo Without quotes: %~1
echo The current working directory is:
cd
pause
使用:
[Files]
Source: "test.bat"; DestDir: "{app}\mysql\db"
我在安装结束时得到这个:
如何在 Code
部分(程序 DeinitializeSetup
)中 运行 一个 bat
文件?
正如我尝试做的:
Exec('"' + installationFolder + '\mysql\db\db.cmd"',
'"'+ installationFolder +'"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
源和目标参数返回到正确的位置。
要执行批处理文件,请使用 Exec
support function。
Exec()
的 Filename
参数中不应有引号。
procedure DeinitializeSetup();
var
InstallationFolder: string;
ResultCode: Integer;
begin
InstallationFolder := ExpandConstant('{app}');
if Exec(InstallationFolder + '\mysql\db\test.bat',
'"' + InstallationFolder + '"',
'', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
Log('Succeeded running batch file');
end
else
begin
Log('Failed running batch file');
end;
end;
如果我安装 test.bat
包含以下内容:
@echo off
echo This is test
echo The provided installation path is %1
echo Without quotes: %~1
echo The current working directory is:
cd
pause
使用:
[Files]
Source: "test.bat"; DestDir: "{app}\mysql\db"
我在安装结束时得到这个: