electron-updater version
2.16.3
Target:
win
I'm facing the issue with updating application installed to the Program Files folder.
I have oneClick: false in config and i'm installing updates with:
setImmediate(() => {
app.removeAllListeners("window-all-closed");
autoUpdater.quitAndInstall(true, true);
});
So when I'm trying to update application running under not admin account, it show UAC notificaton to enable old-uninstaller.exe execution. After I click on Yes it successfully deletes everything from application folder in Program Files but not installs new one. Altough, when I'm trying to update it under admin account it will be updated successfully.
Maybe it's relevant to this issue.
Could you please take a look on it or maybe suggest where should i look?
Ok, figured out myself.
You can use this customInit script in order to make it work as expected:
!macro customInit
${if} $installMode == "all"
${IfNot} ${UAC_IsAdmin}
ShowWindow $HWNDPARENT ${SW_HIDE}
!insertmacro UAC_RunElevated
Quit
${endif}
${endif}
!macroend
Better to prepare PR. Anyway, thanks for solution.
I don't know if it will be the correct code to fix in the PR, so i'll try to ask here
In the multiUser.nsh on line 45 there is the following code:
!macro setInstallModePerAllUsers
StrCpy $installMode all
SetShellVarContext all
!ifdef BUILD_UNINSTALLER # <--
${IfNot} ${UAC_IsAdmin}
ShowWindow $HWNDPARENT ${SW_HIDE}
!insertmacro UAC_RunElevated
Quit
${endif}
!endif # <--
If we delete code with arrows, it will work as expected, but I'm not sure if it's correct to delete this.
Could you please assist me on this?
Cannot answer right now, UAC is quite complicated, need to deep reinvestigate. Could you please provide your full nsis config?
config:
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"include": "./configuration/zzz/include.nsh",
"license": "./configuration/zzz/license.rtf",
"installerHeader": "./configuration/zzz/header.bmp",
"installerSidebar": "./configuration/zzz/side_bar.bmp"
},
include.nsh:
!macro customUnInit
${IfNot} ${Silent}
MessageBox MB_YESNO "Uninstalling the application will delete all related settings. Do you want to continue?" IDYES true IDNO false
false:
Quit
true:
RMDir /r "$PROFILE\AppData\Roaming\zzz"
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "zzz"
${EndIf}
!macroend
!macro customInit
${if} $installMode == "all"
${IfNot} ${UAC_IsAdmin}
ShowWindow $HWNDPARENT ${SW_HIDE}
!insertmacro UAC_RunElevated
Quit
${endif}
${endif}
!macroend
Yeah.... problem is that allowToChangeInstallationDirectory is set to true, but our scripts right now not aware about it (as in case of explicit perMachine), it seems.
I think that this problem is caused by the fact that silent installer is not aware of what permission it has when it tries to install update.
As I can see, uninstallation process is triggered by this line:
ExecWait '"$PLUGINSDIR\old-uninstaller.exe" /S /KEEP_APP_DATA $0 _?=$R1'
But installation (i.e. extracting files to directory) is performed via Nsis7z::Extract "${FILE}"
In the first case, OS will promt user if he's sure to run this .exe under admin rights, but in the second case it will just not extract anything into it without any complains.
@develar was this resolved then? I've had to turn off silent updates in my application as it wouldn't update without the UAC prompt and was waiting for a solution on here?
@chrisbruford Please try latest versions. Should be fixed (and I have manually checked per-machine installation).
@develar I'm Still seeing this with electron-builder 20.39.0. I used @Egorikhin's customInit and it works correctly.
My setttings
"nsis": {
"include": "./build/installer.nsh",
"oneClick": false,
"perMachine": false,
"createDesktopShortcut": true,
"createStartMenuShortcut": true
}
@develar I've got this problem too. I think there are 2 paths here:
perMachine: true
and
perMachine: false
with allowToChangeInstallationDirectory set.
From what I read in the other Issues, perMachine: true works fine now, but if perMachine is false and the user chose an other installation path, after an update, there are some files missing in the chosen path (like the uninstaller). Clearly, the uninstall does not work when the file is missing.
A little more description:
"nsis": {
"oneClick": false,
"perMachine": false,
"allowElevation": true,
"allowToChangeInstallationDirectory": true,
"menuCategory": true,
"runAfterFinish": false
},
The problem exists with the per-user installation.
"devDependencies": {
"electron": "3.0.4",
"electron-builder": "20.39.0"
},
"dependencies": {
"electron-log": "3.0.5",
"electron-updater": "4.0.6"
}
We ran into the same issue, however our solution was to force administrative privileges with
"requestedExecutionLevel": "highestAvailable"
Most helpful comment
A little more description:
The problem exists with the per-user installation.