标准Windows用户的卸载程序问题 [英] Uninstaller trouble with standard Windows user

查看:106
本文介绍了标准Windows用户的卸载程序问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我是否在我在卸载没有提升权限的标准用户安装的程序时遇到问题.

I am having a problem with uninstalling a program installed by a standard user without elevation.

我正在使用INNO安装程序,因此PrivilegesRequired = lowest,并且INNO不提示提升特权,而是为当前用户安装,并创建一个卸载程序,例如uninst000.exe,放在我的应用程序文件夹中,并且我让INNO在我的应用程序的开始"菜单组中放置了卸载程序的图标(所有操作均在当前用户完成). INNO还会在设置/应用和设置"中添加一个项目具有Windows 10小程序(这是问题所在).

I am using INNO Setup, so I have PrivilegesRequired=lowest, and INNO does not prompt for elevated privilege, and installs for the current user, and creates an uninstaller, e.g. uninst000.exe, in my application folder, and I have INNO put an icon for the uninstaller in a Start Menu group for my app (all this done for the current user). INNO also adds an item in the Settings/Apps & Features applet of Windows 10 (this is where the problem comes in).

如果从开始"菜单图标启动了卸载程序,则不会提示提升特权,并且我的应用程序也将毫无问题地进行卸载.

If the uninstaller is launched from the Start menu icon, there is no prompt for elevated privilege, and my app uninstalls with no trouble.

如果卸载程序是从Apps&功能,出现提升权限的提示,并且如果输入了管理员凭据(必须输入),则无法正确卸载该应用程序.有些东西被卸载了,但不是全部.应用程序文件已删除,开始菜单组也已删除,但是INNO的[UninstallRun]部分中的其他清理操作尚未完成.此外,卸载"项也不会从Apps& amp;中的列表中删除.功能.

If the uninstaller is launched from the Apps & Features, a prompt for elevated privilege appears, and if admin credentials are entered (which they must be), the app is not uninstalled correctly. Some things are uninstalled, but not everything. App files are removed, and the start menu group is removed, but additional cleanup actions in INNO's [UninstallRun] section are not getting done. Also, the Uninstall item is not removed from the list in Apps & Features.

所以我的问题是,这是由早先文章中提到的Windows 10错误引起的吗?

So my question is, is this caused by the Windows 10 bug mentioned in the earlier post?

推荐答案

我遵循@MartinPrikryl的建议,要求卸载程序(即InitializeUninstall)检查其正在运行的特权,并检查卸载密钥是否为在HKLM或HKCU注册区域中.到目前为止,我的测试表明这很好.

I have followed the suggestion of @MartinPrikryl to have the uninstaller (i.e. InitializeUninstall) check the privilege it is running under, and check if the uninstall key is in HKLM or HKCU area of registry. So far my testing shows this works well.

function IsRegularUser(): Boolean;
begin
    Result := not (IsAdminLoggedOn or IsPowerUserLoggedOn);
end;

function WasInstalledAsStandardUser(): Boolean; //return true if uninstall key is in Current User area of registry
var
    sUnInstPath: String;
    sUnInstallString: String;
begin
    sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppName")}_is1');
    sUnInstallString := '';
    Result := True;
    { only one of these keys should be present, but if both are, return True for nonadmin }
    if RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then Result:=False;
    if RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString) then Result:=True;
end;

function InitializeUninstall: Boolean;
begin
    if WasInstalledAsStandardUser() and (Not IsRegularUser) then begin
        MsgBox( MyApp was installed with standard user rights, so it must be uninstalled with stardard user rights.'#13'  So use Start/All Programs/MyApp/Uninstall.', mbInformation, MB_OK);
        Result:=False; exit;
    end;
    Result := True;
end;

这篇关于标准Windows用户的卸载程序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆