创新设置执行功能不完全工作



我有一个extractor.bat,我想在安装程序完成安装后运行。

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_modsquick_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;

它在那个特定的pc上工作得很好,但是当我使用代码部分时,它不起作用。我试着调试它,并注意到从提取器输出。install .log的bar在第二行中间被切断,参见:

ARGUMENT 1 (PATH TO CUSTOM MODS): D:GamesGameFolder
ARGUMENT 2 (PATH TO EXTRACT TO): of

一些奇怪的"of",没有别的了

编辑:

试过这个(玩弄cmd宏):

Exec(ExpandConstant('{cmd}'), '/C ' + ExpandConstant('{app}') + 'res_modsquick_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_modsquick_fix.bat', ExpandConstant('{app}'), SW_HIDE, ewWaitUntilTerminated, ErrCode);

我看到的一个真正的问题是,您没有将安装文件夹的路径用双引号括起来。因此,如果它包含空格(通常是这样,因为通常安装到Program Files),您的批处理文件将中断。

Exec(
  ExpandConstant('{app}extractor.bat'),
  ExpandConstant('"{app}custom_folder" "{app}" > extractor.log'),
  '', SW_HIDE, ewWaitUntilTerminated, ErrCode);

所以,也许,在安装程序工作的机器上,你安装到一个没有空格的文件夹。在机器上,如果安装程序不能工作,则安装到带有空格的文件夹

最新更新