[英]Inno Setup - Register components as an administrator
基於優秀的Excel加載項安裝程序(Daniel的XL工具箱),我構建了一個安裝文件,其中包括需要注冊一些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
我需要安裝插件,然后在開始注冊文件之前檢查管理員權限,如果用戶沒有,則會顯示一條消息,要求輸入管理員密碼以便進行注冊。 我知道它可以在設置開始時完成,但如果它是標准用戶帳戶,則不會激活插件。 插件需要注冊組件,標准用戶無法正確安裝。
在注冊開始之前,我正在尋找這樣的東西:
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;
對於任何其他方法,我自然是開放的
我也很高興了解沒有管理員權限的域用戶(Windows服務器)應如何繼續安裝插件。
您可以通過以下方式“以管理員身份”執行regsvr32.exe
:
[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;
替代實現是僅為注冊創建子安裝程序,這將需要管理員權限。
有關類似示例,請參閱Inno Setup - 從需要權限的安裝程序訪問非特權帳戶文件夾 。
或者使用相反的方法。 需要管理員權限
[Setup]
PrivilegesRequired=admin
(默認)
但是將文件部署到原始用戶文件夾。
看到我對Inno Setup的回答總是安裝到admin的AppData目錄中 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.