How to run a bat
file in the Code
section (procedure DeinitializeSetup
)?
As I tried to do:
Exec('"' + installationFolder + '\mysql\db\db.cmd"',
'"'+ installationFolder +'"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
Source and destination parameters are returning to the correct locations.
To execute the batch file, use Exec
support function.
There should be no quotes in the Filename
parameter of the Exec()
.
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;
If I install a test.bat
with this contents:
@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
using:
[Files]
Source: "test.bat"; DestDir: "{app}\mysql\db"
I get this at the end of the installation: