Add NSIS script with electron builder to run DPInst.exe during install

4k views Asked by At

I'm using electron-builder to create NSIS Windows installers for my electron app. During install I need to run the included DPInst.exe to make sure drivers get installed.

I can tell electron-builder than I'm including a custom script:

"nsis": {
  "include": "build/installer.nsh"
}

But I can't work out what should be in the installer.nsh

The docs say that I need something like:

!macro customInstall
  !system "echo '' > ${BUILD_RESOURCES_DIR}/customInstall"
!macroend

And I've seen some NSIS commands to run DPInst.exe

ExecWait '"$INSTDIR\resources\DPInst.exe" /sw'

But I'm unsure how to combine them as I can't work out the syntax!

2

There are 2 answers

5
Tim On BEST ANSWER

Well, it was pretty obvious ‍♂️. I just had to combine the two:

!macro customInstall
  ExecWait '"$INSTDIR\resources\DPInst.exe" /sw'
!macroend
2
Swapnil Patwa On

For me, ExecWait '"$INSTDIR\resources\DPInst.exe" /sw' alone wasn't working because of permission issues.

I had to add RequestExecutionLevel admin

installer.nsh looks like -

!macro customHeader
    RequestExecutionLevel admin
!macroend
!macro customInstall   
  ExecWait '"$INSTDIR\ABC_Setup.exe" /sw'
!macroend