Inno Setup 中的 IsAdmin 和 IsAdminInstallMode 有什么区别?

What is the difference between IsAdmin and IsAdminInstallMode in Inno Setup?

真正的区别是什么:

我阅读了帮助,但没有真正理解它:

IsAdminInstallMode: Returns True if Setup is running in administrative install mode or if Uninstall is running with administrative privileges.

IsAdmin: Returns True if Setup/Uninstall is running with administrative privileges.

管理安装 / 管理权限有什么区别?

我问是因为在构建时我收到了这个警告:

Warning: Line 118, Column 6: [Hint] Support function "IsAdminLoggedOn" has been renamed. Use "IsAdmin" instead or consider using "IsAdminInstallMode".

我应该使用哪个,为什么?

如文档所述,IsAdminInstallMode returns True if Setup is running in administrative install mode. 其中管理安装模式表示:

  • The {group} folder is created in the All Users profile.
  • The "auto" form of the directory and Shell Folder constants is mapped to the "common" form.
  • The HKA, uninstall info, and font install root keys will be HKEY_LOCAL_MACHINE.

是否使用管理员安装模式取决于PrivilegesRequired directive。如果安装程序需要特权,您基本上使用目录来声明。


虽然 IsAdmin(又名 IsAdminLoggedOn)为真,但如果安装程序是以管理员权限执行的。所以这是用户控制的东西,而不是安装程序。


IsAdminLoggedOn IsAdminInstallMode Meaning
True True The installer was executed with administrator privileges, and uses them to install the application for all users.
True False The installer was executed with administrator privileges, but does not need them and will still install the application for the current user only.
False False The installer was not executed with administrator privileges, and does not need them as it will install the application for the current user only.
False True Not possible.

IsAdmin 相当于 IsAdminLoggedOn。但通常情况下,您实际上想要 IsAdminInstallMode,而不是 IsAdminLoggedOn。这就是为什么该功能被重命名并拆分为这两个的原因。这取决于你测试什么。