Search code examples
pythonwindowsnsisghostscript

Install a specific dependency using NSIS zip folder


So my project is python-based, and I have already created the .exe file for it using pyinstaller.

Now I have a folder containing,

  • main.exe file
  • README.txt

I am able to make a single executable file, that will install the dependencies related to main.exe, using NSIS. But for my project to run properly, I need to install another software called GhostScript.

I was wondering if there is a way to do so in NSIS itself. Like when it installs the dependencies it automatically installs GhostScript too.

NOTE: It's for a Windows app


Solution

  • Ghostscript also uses NSIS so it supports the same silent install switch as other NSIS installers.

    InstallDir "$ProgramFiles\MyApp"
    RequestExecutionLevel Admin
    
    Page Components
    Page Directory
    Page InstFiles
    
    !include LogicLib.nsh
    
    Section "Ghostscript"
    InitPluginsDir
    File "/oname=$pluginsdir\gsinst.exe" "gs9540w32.exe"
    ExecWait '"$pluginsdir\gsinst.exe" /S' $0
    ${If} $0 <> 0
      MessageBox mb_iconstop "Unable to install Ghostscript!"
      Abort
    ${EndIf}
    SectionEnd
    
    Section
    SetOutPath $InstDir
    File main.exe
    File Readme.txt
    SectionEnd