Inno安装程序 – 以pipe理员身份注册组件

基于卓越的Excel插件安装程序(Daniel's XL Toolbox),我build立了一个安装文件,其中包括需要注册一些ActiveX

[Files] ; The include file makes adds all .XLA and .XLAM files contained in the ; SOURCEDIR to the project. Source: "c:\source\path\MSCOMCTL.OCX"; \ DestDir: "\users\public\EzPasteFiles"; Flags: regserver Source: "c:\source\path\DAS_AX_Knob.dll"; \ DestDir: "\users\public\EzPasteFiles"; Flags: regserver Source: "c:\source\path\GIF89.DLL"; \ DestDir: "\users\public\EzPasteFiles"; Flags: regserver 

我需要插件安装,然后在开始注册文件之前检查是否有pipe理员权限,如果用户没有,则会显示一条消息,要求inputpipe理员密码以便注册。 我知道它可以在设置开始时完成,但如果它是一个标准的用户帐户,插件将不会被激活。 插件需要注册组件,标准用户无法正确安装。

我正在寻找这样的东西在注册开始之前开枪:

 MyProgChecked := not(IsAdminLoggedOn or IsPowerUserLoggedOn); if MyProgChecked = True then begin MsgBox( 'Kindly notice:' #13#13 'It seems as you are not looged as an administrator' #13#13 'Please abort and reinstall EzPaste AS an administrator' #13#13 '(To install As an Adminstrator, just save the exe setup anywhere then Right Click on it to get to this feature or ask your IT administrator for proper directives)', mbConfirmation, MB_OK); { Popup message asking for Pwd } ExitProcess(0); end; 

对于其他方法,我自然是开放的

我也很高兴能够理解没有pipe理员权限的域用户(Windows服务器)应该如何继续安装插件。

你可以这样执行regsvr32.exe “以pipe理员身份”:

 [Files] Source: "MyDll.dll"; DestDir: "{app}"; AfterInstall: RegMyDll [Code] procedure RegMyDll; var Path: string; RegSvr: string; Params: string; Registered: Boolean; ErrorCode: Integer; begin Path := ExpandConstant(CurrentFilename); RegSvr := 'regsvr32.exe'; Params := Format('/s "%s"', [Path]); Log(Format('Registering %s using "%s" %s', [Path, RegSvr, Params])); Registered := ShellExec('runas', RegSvr, Params, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode); if Registered and (ErrorCode = 0) then begin Log(Format('Registered %s', [Path])); end else begin MsgBox(Format('Registering %s failed with code %d', [Path, ErrorCode]), mbError, MB_OK); end; end; 

高登记


另一种实现是为注册创build子安装程序,只需要pipe理员权限。

有关类似示例,请参阅Inno Setup – 从安装程序访问需要权限的非特权帐户文件夹 。


或者使用相反的方法。 需要使用pipe理员权限

 [Setup] PrivilegesRequired=admin 

(这是默认)

但是将文件部署到原始的用户文件夹。
看到我的答案Inno安装程序总是安装到pipe理员的AppData目录 。