简体   繁体   中英

Not able to register and unregister .dll file through electron-builder custom NSIS include script

I have created a electron desktop app and created a installer using electron-builder .

Now I want to add capability of registering a .dll file at the time of installation of my desktop app and unregistering it at the time of uninstallation .

My installer.nsh file is

!macro customInstall
  Exec "regsvr32.exe $INSTDIR\resources\app.asar.unpacked\node_modules\obs-studio-node\obs-virtualsource.dll"
!macroend

!macro customUnInstall
  Exec "regsvr32.exe /u $INSTDIR\resources\app.asar.unpacked\node_modules\obs-studio-node\obs-virtualsource.dll"
!macroend

My electron-builder config is

"build": {
    "nsis": {
      "include": "installer.nsh"
    },
    "mac": {
      "icon": "build/icon.png"
    },
    "win": {
      "icon": "build/icon.png"
    }
  }

But this is not working for me. I have tried both Exec and ExecWait none is working.
What I am missing to make it working?

Are you running the installer as admin? Registering the.dll requires administrator rights.

Set admin rights in your script first with:

RequestExecutionLevel admin

Try the below options,

!macro customInstall
Exec "regsvr32.exe 
$INSTDIR\resources\app.asar.unpacked\node_modules\obs-studio-node\obs-virtualsource.dll"
!macroend

!macro customUnInit
Exec "regsvr32.exe /u 
$INSTDIR\resources\app.asar.unpacked\node_modules\obs-studio-node\obs-virtualsource.dll"
!macroend

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM