I have a extractor.bat that I would like to run in after installer finishes installing everything.
Extractor.bat contains :
echo ARGUMENT 1 (PATH TO CUSTOM MODS): %1
echo ARGUMENT 2 (PATH TO EXTRACT TO): %2
set custommods=%1
set wotpath=%2
IF EXIST %custommods%\*.zip (
for /F "delims=" %%I IN (' dir /b /s /a-d %custommods%\*.zip ') DO (
"7za.exe" x "%%I" -o%wotpath% -y
)
)
IF EXIST %custommods%\*.7z (
for /F "delims=" %%I IN (' dir /b /s /a-d %custommods%\*.7z ') DO (
"7za.exe" x "%%I" -o%wotpath% -y
)
)
This is part of ssPostInstall code:
begin
if (CurStep=ssDone) then
begin
Exec(ExpandConstant('{app}\extractor.bat'), ExpandConstant('{app}\custom_folder {app}\ > extractor.log'), '', SW_HIDE, ewWaitUntilTerminated, ErrCode);
Exec(ExpandConstant('{app}\res_mods\quick_fix.bat'), '', '', SW_HIDE, ewWaitUntilTerminated, ErrCode);
logfilepathname := expandconstant('{log}');
logfilename := ExtractFileName(logfilepathname);
newfilepathname := expandconstant('{app}\') + 'Installer.log';
filecopy(logfilepathname, newfilepathname, false);
end;
end;
The problem is that this function is working fine on my PC but don't work on some other pc, even without any antivir. Why is that happening?
I've recently moved that extractor execution to the [CODE] section, previously was in [RUN] section as one line:
Filename: "{tmp}\extractor.bat"; Parameters: " ""{app}\custom_folder"" ""{app}\"" "; flags: runhidden;
And it was working fine on that particular pc, however when I use the code section it's not working. I have tried to debug it, and noticed that output from extractor.bar to Installer.log is being cut out in middle of second line, see:
ARGUMENT 1 (PATH TO CUSTOM MODS): D:\Games\GameFolder
ARGUMENT 2 (PATH TO EXTRACT TO): of
Some strange "of" and nothing more.
Edit:
Tried this (to toy with cmd macro):
Exec(ExpandConstant('{cmd}'), '/C ' + ExpandConstant('{app}') + '\res_mods\quick_fix.bat', ExpandConstant('{app}'), SW_HIDE, ewWaitUntilTerminated, ErrCode);
and it wasn't executed at all, of course I have a quick_fix.bat in that folder present.
edit2:
I am currently using this:
Exec(ExpandConstant('{app}\extractor.bat'), ExpandConstant('"{app}\Custom_mods" "{app}" > _Extractor.log'), '', SW_HIDE, ewWaitUntilTerminated, ErrCode);
And it works, but not for everyone, works for me thought. It can install to folders that contains names with spaces too.
edit3:
[Files]
Source: "{#CompPath}\7za.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "{#CompPath}\7za.dll"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "{#CompPath}\7zxa.dll"; DestDir: "{tmp}"; Flags: deleteafterinstall
Edit:
I have tried to make quick_fix.bat to work, as it's easier macro, and it's not being executed as well.
[Files]
Source: "{#CompPath}\quick_fix.bat"; DestDir: "{app}\res_mods\"; Flags: deleteafterinstall
[CODE]
Exec(ExpandConstant('{cmd}'), '/C ' + ExpandConstant('{app}') + '\res_mods\quick_fix.bat', ExpandConstant('{app}'), SW_HIDE, ewWaitUntilTerminated, ErrCode);