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

Time:02-28

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?

CodePudding user response:

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.

  • Related