NSIS 安装程序错误 - 没有足够的内存资源可用于处理此命令

NSIS Installer error - Not enough memory resources available to process this command

我已经使用 NSIS 包创建了一个安装程序来安装我自己的软件以及一些第 3 方软件,例如 Notepad++ 和 winPython。批处理脚本正在 运行 安装 notepad++ 和 winPython。打包到安装程序中的 winPython 是压缩格式“winPython3940.7z”。使用以下 .nsh 脚本将其作为安装程序的一部分解压缩到一个文件夹中。

; --------------------------------------------------------------------------------------------
; Install Third Party Software
; --------------------------------------------------------------------------------------------
Section "Install Third Party Software"
; Execute Notepad++ installer
${If} $Notepad_userDecision == "1"      
    DetailPrint ""
    DetailPrint "----------------- Install Notepad++ -----------------"
    DetailPrint ""

    DetailPrint "Create Notepad++ install batch..."
    ${textreplace::ReplaceInFile} "${TEMP_PATH}installer_template.bat" "${TEMP_PATH}install_notepad.bat" "#INSTALL_CMD" '"${TEMP_PATH}Notepad\npp.7.8.7.Installer.x64.exe" /S' "/S=1 /C=1 /AO=1 /PI=0 /PO=0"  [=10=]
    DetailPrint "Execute Notepad++ install batch..."
    nsExec::Exec "${TEMP_PATH}install_notepad.bat"
${EndIf}

; --------> PROBLEMATIC PART: Execute WinPython installer
${If} $WinPython_userDecision == "1"
    ; Delete old winPython Installation
    DetailPrint ""
    DetailPrint "----------------- Delete old WinPython installation -----------------"
    DetailPrint ""
    
    DetailPrint "Create WinPython uninstall batch..."
    ${textreplace::ReplaceInFile} "${TEMP_PATH}installer_template.bat" "${TEMP_PATH}uninstall_winpython.bat" "#INSTALL_CMD" 'if exist ("${PYTHON_PATH}" rmdir /s /q "${PYTHON_PATH}")' "/S=1 /C=1 /AO=1 /PI=0 /PO=0"  [=10=]
    DetailPrint "Execute WinPython uninstall batch..."
    nsExec::Exec "${TEMP_PATH}uninstall_winpython.bat"
    
    DetailPrint ""
    DetailPrint "----------------- Install WinPython -----------------"
    DetailPrint ""

    DetailPrint "Create WinPython install batch..."
    ${textreplace::ReplaceInFile} "${TEMP_PATH}installer_template.bat" "${TEMP_PATH}install_winPython.bat" "#INSTALL_CMD" 'if exist "C:\Program Files-Zipz.exe" ("C:\Program Files-Zipz.exe" x "${TEMP_PATH}WinPython\winPython3940.7z" -o${PYTHON_PATH})' "/S=1 /C=1 /AO=1 /PI=0 /PO=0"  [=10=]
    DetailPrint "Execute WinPython install batch..."
    nsExec::Exec "${TEMP_PATH}install_winPython.bat"
${EndIf}
SectionEnd

Notepad++ 与 winPython 一样完美安装(没有任何弹出命令 windows),但前者有几个软错误。正在处理 2 个批处理脚本 运行 删除旧的 winPython 安装,然后安装新的。当安装程序是 运行 时,这两个脚本都会打开 2 个单独的 cmd windows,其中第二个在第一个关闭后打开。脚本得到完美执行,但它们都包含“没有足够的内存资源可用于处理此命令” winPython uninstaller script's cmd window and winPython installer script's cmd window.

如何解决这个问题?

该消息不是来自 NSIS,它一定来自批处理文件中的某些内容,也许是 7-Zip。

没有理由使用批处理文件来删除东西,只需使用 NSIS:

Section "Prepare Example"
CreateDirectory "$temp\fakepython\something\somethingelse"
CopyFiles /SILENT /FILESONLY "$WinDir\*.exe" "$temp\fakepython" ; Dummy files
SectionEnd


!include LogicLib.nsh
Var MyDetectedPythonPath

Section
StrCpy $MyDetectedPythonPath "$temp\fakepython" ; Replace this with the correct logic to find Python.

${If} ${FileExists} "$MyDetectedPythonPath\*" ; Probably a good idea to replace * with something like python.exe so you know you found the correct directory
    RMDir /R "$MyDetectedPythonPath"
${EndIf}

DetailPrint "Installing python..."
StrCpy  '"$sysdir\cmd.exe" /C ping localhost' ; Replace this with your real command
nsExec::Exec ''
Pop [=10=]
DetailPrint "Exit code [=10=]"
SectionEnd

您也可以尝试 this 7z plug-in 而不是调用 7z-exe。