Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Machine-wide NSIS installer launches application as administrator #864

Closed
ghost opened this issue Oct 31, 2016 · 22 comments · May be fixed by qcif/data-curator#563
Closed

Machine-wide NSIS installer launches application as administrator #864

ghost opened this issue Oct 31, 2016 · 22 comments · May be fixed by qcif/data-curator#563

Comments

@ghost
Copy link

ghost commented Oct 31, 2016

  • Version: 7.14.2
  • Target: Windows

With a machine-wide NSIS installer (a UAC dialog popped when launching), having the "Run $application" checkbox checked, my application runs with administrative privileges; I expected my application to be run with non-elevated privileges.

@develar
Copy link
Member

develar commented Oct 31, 2016

We do use UAC_AsUser_ExecShell https://github.com/electron-userland/electron-builder/blob/master/templates/nsis/boringInstaller.nsh#L9 and it still doesn't help? Or... we use it only in case of boring installer.

@ghost
Copy link
Author

ghost commented Oct 31, 2016

Correct. I noticed this when launching an executable with shell.openItem, expecting to see a UAC dialog, but I did not.

Here are screenshots from procexp:

Launching application normally from desktop shortcut
regular

Launching application at end of installer
installer

@ghost
Copy link
Author

ghost commented Nov 1, 2016

From the NSIS UAC page, I see the following line in the code example:

RequestExecutionLevel user ; << Required, you cannot use admin!

Perhaps the electron-builder NSIS template is incorrectly requesting administrative privileges via RequestExecutionLevel?

@develar
Copy link
Member

develar commented Nov 1, 2016

No. one click machine wide installer must use admin because it is one click, not boring installer. I will investigate issue.

@develar
Copy link
Member

develar commented Nov 2, 2016

Reproduced (to reproduce, your account should be not administrator).

@develar
Copy link
Member

develar commented Nov 2, 2016

Fixed — StdUtils.ExecShellAsUser must be used. https://github.com/lordmulder/stdutils

@develar develar added bug and removed investigate labels Nov 2, 2016
@develar develar closed this as completed in 4ac12bf Nov 2, 2016
@develar
Copy link
Member

develar commented Nov 2, 2016

Thanks for spotting it and clear report.

@ghost
Copy link
Author

ghost commented Nov 2, 2016

I just upgraded to 7.18.1, re-built my installer, and I am experiencing the same issue.

@ghost
Copy link
Author

ghost commented Nov 2, 2016

My NSIS configuration:

"nsis": {
    "oneClick": false,
    "perMachine": true,
    "guid": "939693fe-aa4b-4da5-b1de-34700e4f1c83"
}

@develar
Copy link
Member

develar commented Nov 2, 2016

I created test user without admin rights and tested — works for me (win 10). Ok — will try to test it again.

@develar
Copy link
Member

develar commented Nov 2, 2016

Ouch, "oneClick": false, — boring installer, not one-click?

@ghost
Copy link
Author

ghost commented Nov 2, 2016

boring installer, not one-click?

Correct.

@develar
Copy link
Member

develar commented Nov 3, 2016

Every user of NSIS boring installer should upgrade to next electron-builder version as soon as possible.

@anran800
Copy link

I include file 'installer.nsh' .test successful
!macro customInstall
StrCpy $appExe "$INSTDIR${APP_EXECUTABLE_FILENAME}"
WriteRegStr HKCU "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" "$appExe" "RUNASADMIN"
!macroend

@DxCx
Copy link

DxCx commented May 10, 2017

@anran800 thanks for your solution, it helped 👍
just one correction, you are missing '\', so it should be:

!macro customInstall
StrCpy $appExe "$INSTDIR\${APP_EXECUTABLE_FILENAME}"
WriteRegStr HKCU "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" "$appExe" "RUNASADMIN"
!macroend

@DxCx
Copy link

DxCx commented May 10, 2017

for uninstalling the rule when application uninstalls i used:

!macro customUnInstall
DeleteRegValue HKCU "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" "$INSTDIR\${APP_EXECUTABLE_FILENAME}"
!macroend

@develar
Copy link
Member

develar commented May 11, 2017

@anran800 Why do you need to do it, what's wrong? This issue was fixed.

@DxCx
Copy link

DxCx commented May 11, 2017

@develar what do you mean fixed?
This marks the installed exe as RunAsAdmin

@develar
Copy link
Member

develar commented May 11, 2017

@DxCx So, please do not comment here, but create new issue and request feature :)

@DxCx
Copy link

DxCx commented May 11, 2017

that's not a new issue :)
i got here with google looking for solution and found halfworking one,
just wanted to share my experience with the others who will get here.

@develar
Copy link
Member

develar commented May 11, 2017

@DxCx This issue about "installer by mistake runs installed app as admin" ;)

@DxCx
Copy link

DxCx commented May 11, 2017

then you are right @develar , my bad =) i was getting here searching the exact opposite 🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants