want: win-unpacked dir, ${APP_EXECUTABLE_FILENAME}.exe requestedExecutionLevel admin
config:
"perMachine": true,
"oneClick": false,
"allowElevation": true,
the ${APP_EXECUTABLE_FILENAME}.exe manifest always display result:
<?xml version="1.0" encoding="utf-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true/pm</dpiAware>
<disableWindowFiltering xmlns="http://schemas.microsoft.com/SMI/2011/WindowsSettings">true</disableWindowFiltering>
</asmv3:windowsSettings>
</asmv3:application>
<ms_compatibility:compatibility xmlns:ms_compatibility="urn:schemas-microsoft-com:compatibility.v1" xmlns="urn:schemas-microsoft-com:compatibility.v1">
<ms_compatibility:application>
<ms_compatibility:supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"></ms_compatibility:supportedOS>
<ms_compatibility:supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"></ms_compatibility:supportedOS>
<ms_compatibility:supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></ms_compatibility:supportedOS>
<ms_compatibility:supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"></ms_compatibility:supportedOS>
<ms_compatibility:supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></ms_compatibility:supportedOS>
</ms_compatibility:application>
</ms_compatibility:compatibility>
</assembly>
i want
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
If one-click is false, UAC will be requested during installation.
It seems, you need to set allowElevation to false also. But I see that in this case requestedExecutionLevel is also not set to admin Please check. If so, it will be fixed today.
For what do you disable one-click installation?
Thank you so soon reply.
Set allowElevation to false,I tried it,but it not working ;
I want UAC will be requested during running;
@develar disable one-click,because I want set allowToChangeInstallationDirectory true
Cannot reproduce — 19.20.1,
nsis: {
oneClick: false,
allowElevation: false,
perMachine: true,
}
Installer has RequestExecutionLevel admin and requires admin to run.
I misunderstood you. Do you want ability to specify requestedExecutionLevel for application, not only for installer, right?
@develar I have the same issue. How to specify requestedExecutionLevel for application?
@SZzzzz it doesn't work?
@SZzzzz my config,it‘s working
"win": {
"icon": "resources/icon.ico",
"requestedExecutionLevel": "requireAdministrator",
"target": [
"nsis"
]
},
"nsis": {
"artifactName": "${productName}-${version}.${ext}",
"perMachine": true,
"oneClick": false,
"guid": "21b4651a-e93e-4793-a19c-2f102a494a26",
"allowToChangeInstallationDirectory": true,
"menuCategory": false,
"installerIcon": "resources/icon.ico",
"installerHeaderIcon": "resources/icon.ico",
"allowElevation": true,
"warningsAsErrors": false,
"installerLanguages": "zh_CN",
"language": 2052,
"deleteAppDataOnUninstall": true
},
@IDrinkMoreWater Thank you DaXiongDi, it works.
@develar Thank you, it works now.
I'm on electron-builder 20.8.1, and having trouble getting "requireAdministrator" to work properly with one-click nsis installs.
Our users are on Win10x64, and have administrator rights.
Main reason to want users to run as admin is a workflow step within the app that involves writing to the local fs. Things work as desired when users right-click to choose "Run as Administrator", but of course we can't rely on that as it's a terrible UX. I'm new to electron and desktop app dev, and would be very grateful for any help here.
I've tried all the relevant permutations (e.g. w/ oneClick: false and allowElevation: true, as well as experimenting with perMachine: false) but can't seem to configure things in a way that behaves the same as when the user right-clicks to run as admin.
I'm using an electron-builder.yml file for config, and it contains something like this:
win:
requestedExecutionLevel: "requireAdministrator"
target:
target: "nsis"
arch: "x64"
icon: "static/panda-icon.ico"
files: "!**/bin/mac/**/*"
nsis:
oneClick: true # false==assisted
perMachine: true # true means C:\Program Files\ (vs per-user, e.g. C:\Users\cweekly\AppData\Local\Programs\)
# allowElevation: true # only valid w/ assisted (oneClick false)
# allowToChangeInstallationDirectory: true # only valid w/ assisted (oneClick false)
@cweekly did you manage to find a solution? I found that on version electron-builder@^20.2.0 your config will work I can't get it working on version 20.28.4 though
@gjavi1 No, this issue was still in the backlog when I stopped work on the relevant project back in June. Thanks for reproducing it, anyway!
Most helpful comment
@SZzzzz my config,it‘s working