我想知道我是否遇到了与this post中讨论的Windows 10相同的错误。
我在卸载由标准用户安装的程序时遇到问题而没有提升。
我正在使用INNO安装程序,因此我有PrivilegesRequired =最低,并且INNO不提示提升权限,并为当前用户安装,并创建卸载程序,例如uninst000.exe,在我的应用程序文件夹中,我有INNO在我的应用程序的“开始菜单”组中为卸载程序添加了一个图标(所有这些都是为当前用户完成的)。 INNO还在Windows 10的“设置/应用和功能”小程序中添加了一个项目(这就是问题所在的位置)。
如果从“开始”菜单图标启动卸载程序,则不会提示提升权限,并且我的应用程序卸载时没有任何问题。
如果从应用和功能启动卸载程序,则会显示提升权限提示,如果输入管理员凭据(必须是这些凭据),则不会正确卸载应用程序。有些东西是卸载的,但不是一切。删除了应用程序文件,并删除了开始菜单组,但INNO的[UninstallRun]部分中的其他清理操作无法完成。此外,“应用和功能”中的列表中不会删除“卸载”项。
所以我的问题是,这是由早期帖子中提到的Windows 10错误造成的吗?
我遵循@MartinPrikryl的建议让卸载程序(即InitializeUninstall)检查它运行的权限,并检查卸载密钥是否在HKLM或HKCU注册表区域。到目前为止,我的测试表明这很有效。
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;