Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
628 views
in Technique[技术] by (71.8m points)

registry - Windows control panel requires admin privileges when uninstall via NSIS

I have a NSIS installer/uninstaller which install an application for the current user only. There are registry writings in HKCU in order to make the application appears in control panel. It works perfectly well. However, when I try to uninstall the application from control panel, it pop-up the admin privileges pop-up box (the AUC stuff) and run the uninstaller as admin. Therefore HKCU is related to the admin account and not the user account. In this way, a user can 'uninstall' the admin application! I need to allow a user to uninstall the application without admin privileges.

I am already using !include MultiUser.nsg et al. I've also noticed that it is possible to uninstall some random/default MS applications from control panel at user level (which doesn't require admin privileges) so I know it is possible.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Uninstalling from the old "Programs and Features" in the classic control panel works just fine without UAC prompts. I just tested on Windows 10.0.16184 with this:

InstallDir $TempTest
RequestExecutionLevel user

Section
SetOutPath  "$InstDir"
WriteUninstaller "$InstDirUninst.exe"
WriteRegStr HKCU "SoftwareMicrosoftWindowsCurrentVersionUninstallNSIS_W10_HKCU_Test" "DisplayName" "NSIS W10 HKCU Test"
WriteRegStr HKCU "SoftwareMicrosoftWindowsCurrentVersionUninstallNSIS_W10_HKCU_Test" "UninstallString" '"$InstDirUninst.exe"'
SectionEnd

Section Uninstall
DeleteRegKey HKCU "SoftwareMicrosoftWindowsCurrentVersionUninstallNSIS_W10_HKCU_Test"
Delete "$InstDirUninst.exe"
RMDir "$InstDir"
SectionEnd

Classic ARP

There is however a known issue if you do the same in the settings app, it will force UAC elevation even for HKCU uninstallers: Modern ARP

This issue in the settings app has existed for a couple of years now and I don't think Microsoft cares.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...