我有一個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是一個單獨的日誌,你可以在我的代碼中看到它,但它不受任何問題的影響。我只是將它包括在內以便更好地概述這部分。 –