我有一个需要使用管理权限运行的InstallShield InstallScript项目。简而言之,我需要从InstallShield:
到目前为止,我知道我可以做这样的事情来查找我是否拥有管理员权限:
//---------------------------------------------------------------------------
// Run As Utilities Library
//---------------------------------------------------------------------------
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
//---------------------------------------------------------------------------
export prototype UserRightsCheck();
function UserRightsCheck()
begin
MessageBox(INSTALLPROPERTY_INSTALLLOCATION, INFORMATION);
if(USER_ADMINISTRATOR) then
MessageBox("hello Admin", INFORMATION); // testing only
// do nothing we are an admin
else
MessageBox("hello user", SEVERE); // testing only
RunAsAdmin();
endif;
end;
export prototype RunAsAdmin();
function RunAsAdmin()
begin
STRING username = "myUserID";
STRING password = "myPassword";
STRING filepath = INSTALLPROPERTY_INSTALLLOCATION;
RunAsUserAccount(username,password,filepath);
end;
export prototype RunAsUserAccount();
function RunAsUserAccount()
STRING username;
STRING password;
STRING filepath;
begin
/*
Is this the best way to do this? this is the function I need help with
This seems like a hack
*/
if ( SYSINFO.WINNT.bWinXP ) then
LAAW_SHELLEXECUTEVERB = "open"; // target PC is on Windows XP
else
LAAW_SHELLEXECUTEVERB = "runas"; // Windows 7 (or Vista)
endif;
LaunchApplication(
filepath
,"" // Arguments
,"" // Directory
,SW_NORMAL // Use Window Mode
,0
,LAAW_OPTION_WAIT_INCL_CHILD | LAAW_OPTION_USE_SHELLEXECUTE
);
end;
如何重新启动安装程序?这可以在Wise Package Studio和许多其他工具中完成,但我还没有找到答案如何在这个工具中完成。
我知道我可以做一个runas.exe或psexec.exe,但感觉就像一个黑客,听起来像是一个糟糕的做法。经过大约一天的阅读后,我仍然不确定如何做到这一点。
有人可以指出我在InstallShield中以正确方式执行此操作的正确方向吗?
答案 0 :(得分:1)
告诉MessageBox中的用户使用管理员权限重新启动设置。说明他们可以通过右键单击资源管理器中的setup.exe ,然后点击" 以管理员身份运行"来执行此操作。然后在UAC提示符下确定。这是概念上的"清洁"这样做的方法,因为你没有意外。
正如我在上面的评论中已经说过的那样,请三思而后行 Installscript MSI 。这是非常错误的。更好的选择是带有Installscript自定义操作代码的基本MSI 。
基本MSI是标准MSI,Installscript自定义操作不会干扰设置GUI或整体MSI操作。在 Installscript MSI 中,整个安装顺序是受Installscript控制的,这会导致严重的错误 - 其中一些没有解决方法或修复(甚至在发现后几年)。
答案 1 :(得分:0)
也许这与您所寻找的一致:How can I make the installer Run as admin。 Also check this
如果使用MSI而不是Installscript并使用提升权限的内置MSI概念,则可以使用命令行中设置的MSI属性来安装具有提升权限的任何位置:msiexec /i MySetup.MSI USER=OneUser /PASS=PassWord /qn
。只是陈述什么是可能的,也许更容易。