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

发布于 2025-01-10 03:40:00 字数 2689 浏览 0 评论 0原文

我使用 NSIS 包创建了一个安装程序来安装我自己的软件以及一些第三方软件,例如 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"  $0
    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"  $0
    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\7-Zip\7z.exe" ("C:\Program Files\7-Zip\7z.exe" x "${TEMP_PATH}WinPython\winPython3940.7z" -o${PYTHON_PATH})' "/S=1 /C=1 /AO=1 /PI=0 /PO=0"  $0
    DetailPrint "Execute WinPython install batch..."
    nsExec::Exec "${TEMP_PATH}install_winPython.bat"
${EndIf}
SectionEnd

Notepad++ 和 winPython 都可以完美安装(没有任何弹出的 cmd 窗口),但前者有一些软错误。正在运行 2 个批处理脚本来删除旧的 winPython 安装,然后安装新的。当安装程序运行时,这两个脚本都会打开 2 个单独的 cmd 窗口,其中第二个窗口在第一个窗口关闭后打开。脚本完美执行,但它们都包含“没有足够的内存资源可用于处理此命令winPython 卸载程序脚本的 cmd 窗口winPython 安装程序脚本的 cmd 窗口

我该如何解决这个问题?

I have created an installer using NSIS package to install my own software along with some 3rd party softwares such as Notepad++ and winPython. Batch scripts are being run to install notepad++ and winPython. The winPython which is packaged into the installer is in a zipped format "winPython3940.7z". This is being unzipped into a folder as a part of the installer using the following .nsh script.

; --------------------------------------------------------------------------------------------
; 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"  $0
    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"  $0
    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\7-Zip\7z.exe" ("C:\Program Files\7-Zip\7z.exe" x "${TEMP_PATH}WinPython\winPython3940.7z" -o${PYTHON_PATH})' "/S=1 /C=1 /AO=1 /PI=0 /PO=0"  $0
    DetailPrint "Execute WinPython install batch..."
    nsExec::Exec "${TEMP_PATH}install_winPython.bat"
${EndIf}
SectionEnd

Notepad++ gets installed perfectly (without any popup cmd windows) as well as winPython, but the former has a couple of soft bugs. 2 batch scripts are being run to delete an old winPython installation and then installation the new one. When the installer is running, both of these scripts open up 2 individual cmd windows where the second one opens up after the first one is closed. Scripts get executed perfectly but they both contain "Not enough memory resources available to process this command"
winPython uninstaller script's cmd window and winPython installer script's cmd window.

How do I resolve this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宫墨修音 2025-01-17 03:40:00

该消息不是来自 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 $1 '"$sysdir\cmd.exe" /C ping localhost' ; Replace this with your real command
nsExec::Exec '$1'
Pop $0
DetailPrint "Exit code $0"
SectionEnd

您也可以尝试 这个 7z 插件-in 而不是调用 7z-exe。

That message is not coming from NSIS, it must be from something inside your batch file, perhaps 7-Zip.

There is no reason to use a batch file to delete something, just use 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 $1 '"$sysdir\cmd.exe" /C ping localhost' ; Replace this with your real command
nsExec::Exec '$1'
Pop $0
DetailPrint "Exit code $0"
SectionEnd

You could also try this 7z plug-in instead of calling 7z-exe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文