我有一个extractor.bat,我想在安装程序完成所有安装后运行。Inno设置exec函数没有完全工作
Extractor.bat包含:
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
)
)
这是ssPostInstall代码部分:
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;
端;
问题是,这个功能在我的电脑上工作正常,但不能在其他电脑上工作,即使没有任何antivir。为什么会发生?
最近我感动的是提取执行到[CODE]部分,以前是在[RUN]部分为一个行:
Filename: "{tmp}\extractor.bat"; Parameters: " ""{app}\custom_folder"" ""{app}\"" "; flags: runhidden;
它然而,关于这台主机工作正常,当我使用它不工作的代码部分。我试图调试它,并注意到输出extractor.bar到Installer.log在第二行的中间被切出,请参阅:
ARGUMENT 1 (PATH TO CUSTOM MODS): D:\Games\GameFolder
ARGUMENT 2 (PATH TO EXTRACT TO): of
一些奇怪的“的”,仅此而已。
编辑:
想这(与CMD宏玩具):
Exec(ExpandConstant('{cmd}'), '/C ' + ExpandConstant('{app}') + '\res_mods\quick_fix.bat', ExpandConstant('{app}'), SW_HIDE, ewWaitUntilTerminated, ErrCode);
,并没有执行可言,我当然在当前文件夹中的quick_fix.bat。
EDIT2:我目前正在使用这个
:
Exec(ExpandConstant('{app}\extractor.bat'), ExpandConstant('"{app}\Custom_mods" "{app}" > _Extractor.log'), '', SW_HIDE, ewWaitUntilTerminated, ErrCode);
而且它的工作原理,但并不适合所有人,对我的作品想。它可以安装到包含名称和空格的文件夹。
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
编辑:
我试图让quick_fix.bat工作,因为它更容易宏,它没有被执行为好。
[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);
从这里开始:[调试从Inno Setup安装程序执行的非工作批处理文件](http:// stackoverflow。com/questions/37324386/debugging-non-working-batch-file-executed-from-inno-setup-installer) –
*“注意到从extractor.bar到Installer.log的输出在第二行中间被截断” * - 你是不是指'extractor.log',而不是'Installer.log'? –
Installer.log是一个单独的日志,你可以在我的代码中看到它,但它不受任何问题的影响。我只是将它包括在内以便更好地概述这部分。 –