INNO 设置:在“所有用户”模式下安装,在尝试执行已安装的软件时仍然需要非管理员用户的管理员权限

问题描述 投票:0回答:1

向社区问好,

我使用 INNO 设置的打包软件遇到以下问题。
我使用以下选项来允许用户为所有或当前用户选择安装。

PrivilegesRequiredOverridesAllowed=对话框

现在作为管理员,我选择为“所有用户”安装。当然,并非所有“其他用户”都是管理员。
我安装到程序文件。然后,当我以访客用户身份登录时,我希望在没有管理员权限的情况下运行已安装的软件。创建的桌面图标的右下角仍然有这个“盾牌”,并且需要管理员密码才能运行该软件。

在我的例子中,“所有用户”安装选项似乎意味着“所有管理员用户”。
我正在附上我的 setup.iss 文件。我尝试过各种不同的选择,但没有任何效果。
我的问题与 INNO 创建的桌面图标有关还是与 [Setup] 部分中的选项有关? 我很确定我在选项中遗漏了一些东西。

感谢大家的帮助

; Script generated by the Inno Script Studio Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define year GetDateTimeString('yyyy', '', '')
#define gei "Setup 0.0.0.exe"
#define gei_version "0.0.0"

#include "../packaging/config.ini"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppCopyright=Copyright (C) {#year} GEP
AppId={{D1E5279A-807D-414F-A0E3-0A414379D0F0}
AppVerName=Suite 0.0.0
UninstallDisplayName=Pattern 0.0.0
SetupMutex=SetupMutex{#SetupSetting("AppId")}
AppPublisher=company
AppSupportURL={#SetupSetting("AppPublisherURL")}
AppUpdatesURL={#SetupSetting("AppPublisherURL")}
ArchitecturesInstallIn64BitMode=x64
Compression=lzma/normal
LZMANumBlockThreads=2
AlwaysRestart=no
CloseApplications=no
UsePreviousAppDir=no
DefaultGroupName=Pattern
DefaultDirName={autopf}\{#SetupSetting("DefaultGroupName")} 3.x
UninstallFilesDir={code:GetDataDir}
LicenseFile=license.txt
OutputBaseFilename={#SetupSetting("AppName")}
;SetupIconFile=..\resources\icon.ico
SolidCompression=yes
SetupLogging=yes
WindowResizable=no
WizardImageFile=.\logo.bmp
WizardSmallImageFile=.\Loop.bmp
WizardStyle=modern
PrivilegesRequiredOverridesAllowed=dialog
UsePreviousPrivileges=no
DisableDirPage=yes
InfoAfterFile=release_notes.txt

[Types]
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
Name: "StartAfterInstall"; Description: "Display the PDF Readme File"

[Components]
Name: "GEI"; Description: "GEI {#gei_version}"; Flags: checkablealone disablenouninstallwarning
Name: "GEP"; Description: "GEP {#SetupSetting("AppVersion")}"; Flags: checkablealone disablenouninstallwarning

[Files]
Source: ".\UninsIS.dll"; Flags: dontcopy
Source: ".\UninsIS.dll"; DestDir: "{code:GetDataDir}"; Check: Is64BitInstallMode()
Source: ".\UninsIS.dll"; DestDir: "{code:GetDataDir}"; Check: not Is64BitInstallMode()
;Source: ".\Softwares\{#gei}"; DestDir: {code:GetDataDir}; Flags: deleteafterinstall nocompression; Components: GEI
;Source: ".\GEP - Installation Guide.pdf"; DestDir: {code:GetDataDir}; Flags: ignoreversion sign recursesubdirs; Components: GEP
Source: ".\GEP\*"; DestDir: {code:GetDataDir}; Flags: ignoreversion sign recursesubdirs; Components: GEP

[Icons]
Name: "{group}\Pattern {#SetupSetting("AppVersion")}"; Filename: "{code:GetDataDir}\Pattern.exe"; Parameters: "--from_desktop"
Name: "{group}\{cm:UninstallProgram,Pattern {#SetupSetting("AppVersion")}}"; Filename: "{uninstallexe}"
Name: "{autodesktop}\Pattern {#SetupSetting("AppVersion")}"; Filename: "{code:GetDataDir}\Pattern.exe"; Parameters: "--from_desktop"

[Run]
Filename: "{code:GetDataDir}\{#gei}"; Parameters: "/min"; StatusMsg: "Installing GEI... please wait..."; Flags: runhidden; Components: GEI
;Filename: "{code:GetDataDir}\GEP - Installation Guide.pdf"; Tasks: StartAfterInstall; Flags: shellexec runasoriginaluser skipifdoesntexist

[Registry]
Root: "HKLM"; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"; ValueType: String; ValueName: "{code:GetDataDir}\Pattern.exe"; ValueData: "~RUNASADMIN"; Flags: uninsdeletekey noerror

[Code]

type
    SERVICE_STATUS = record
        dwServiceType               : cardinal;
        dwCurrentState              : cardinal;
        dwControlsAccepted          : cardinal;
        dwWin32ExitCode             : cardinal;
        dwServiceSpecificExitCode   : cardinal;
        dwCheckPoint                : cardinal;
        dwWaitHint                  : cardinal;
    end;
    HANDLE = cardinal;

const 
  PathRegistryUninstalled = 'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\';

  SC_MANAGER_ALL_ACCESS = $F003F;
  SERVICE_QUERY_STATUS = $4;
  SERVICE_RUNNING = $00000004;

var
  CompPageVisited: Boolean;
  DefaultCompClickCheck: TNotifyEvent;
  DefaultCompTypeChange: TNotifyEvent;
  DescLabelCompPage: TLabel;            
  DescLabelSelDirPage: TLabel;            
  DescLabelFinPage: TLabel;            
  MySelectDirPage: TInputDirWizardPage;

function IsAppRunning(AppName: string): boolean;

         var
           FWMIService: Variant;
           FSWbemLocator: Variant;
           FWbemObjectSet: Variant;

         begin
           Result := false;
           FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
           FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
           FWbemObjectSet := FWMIService.ExecQuery(Format('SELECT Name FROM Win32_Process Where Name="%s"',[AppName]));
           Result := (FWbemObjectSet.Count > 0);
           FWbemObjectSet := Unassigned;
           FWMIService := Unassigned;
           FSWbemLocator := Unassigned;
         end;

function InitializeSetup(): Boolean;
    var
      Answer: Integer;
    begin
      Result := True;
      while IsAppRunning('Pattern.exe') or IsAppRunning('calculusmaster.exe') do
      begin
        Answer := MsgBox('Setup has detected that Pattern is currently running. \
                          Please stop it, then click OK to continue, or Cancel to exit.', mbError, MB_OKCANCEL);
        if Answer = IDCANCEL then
        begin
          Result := False
          Exit;
        end;
      end;
    end;

function DLLUninstallPrevious(AppId: string; Is64BitInstallMode, IsAdminInstallMode: DWORD): DWORD;
        external 'UninstallISPackage@files:UninsIS.dll stdcall setuponly';

// Wrapper for UninsIS.dll UninstallISPackage() function. Returns 0 for success, non-zero for failure
function UninstallPrevious(): DWORD;

        begin
          result := DLLUninstallPrevious('{D1E5279A-807D-414F-A0E3-0A414379D0F0}', DWORD(Is64BitInstallMode()), DWORD(IsAdminInstallMode()));
        end;

function PrepareToInstall(var NeedsRestart: Boolean): String;

     var
       ResultCode: Integer;

     begin
       Exec(ExpandConstant('{sys}\taskkill.exe'), '/f /im "vodd.exe"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
       Exec(ExpandConstant('{sys}\taskkill.exe'), '/f /im "calculusmaster.exe"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
       Exec(ExpandConstant('{sys}\taskkill.exe'), '/f /im "0mq.exe"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
       Exec(ExpandConstant('{sys}\taskkill.exe'), '/f /im "Pattern.exe"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);

       if WizardForm.ComponentsList.Checked[1] then
          UninstallPrevious()

     end;

function GetDataDir(Param: String): String;

        begin
          Result := MySelectDirPage.Values[0];
        end;

function GetSelectedComponentsCount: Integer;

         var
           I: Integer;           

         begin

           Result := 0;
           for I := 0 to WizardForm.ComponentsList.Items.Count - 1 do
               if WizardForm.ComponentsList.Checked[I] then
                  begin
                    Result := Result + 1;
                  end;
         end;

procedure ComponentsClickCheck(Sender: TObject);

          var
            Count: Integer;

          begin
            DefaultCompClickCheck(Sender);

            Wizardform.NextButton.Enabled := True;
            Count := GetSelectedComponentsCount()
            if Count = 0 then
               Wizardform.NextButton.Enabled := False;      

          end;

procedure InitializeWizard();

          begin

            MySelectDirPage := CreateInputDirPage(wpSelectComponents, 'Select Destination Location', 
                                                                      'Where it should be installed?',
                                                                      'To continue click Next. If you would like to select a different folder, click Browse', False, '' );            
            MySelectDirPage.Add('');
            MySelectDirPage.Values[0] := ExpandConstant('{pf}\Pattern 3.x');

            if Pos('ALLUSERS', GetCmdTail()) = 0 then           
               MySelectDirPage.Values[0] := ExpandConstant('{userappdata}\Pattern 3.x');

            DefaultCompClickCheck := WizardForm.ComponentsList.OnClickCheck;
            WizardForm.ComponentsList.OnClickCheck := @ComponentsClickCheck;
            DefaultCompTypeChange := WizardForm.TypesCombo.OnChange;
            WizardSelectComponents('GEI')
            WizardSelectComponents('GEP')

            DescLabelCompPage := TLabel.Create(WizardForm);
            DescLabelCompPage.Parent := WizardForm.ComponentsList;            
            DescLabelCompPage.Color := clRed;
            DescLabelCompPage.Top := 90;
            DescLabelCompPage.Left := 2;

            DescLabelSelDirPage := TLabel.Create(WizardForm);
            DescLabelSelDirPage.Parent := MySelectDirPage.Surface;            
            DescLabelSelDirPage.Color := clRed;
            DescLabelSelDirPage.Top := 100;
            DescLabelSelDirPage.Left := 2;

            DescLabelFinPage := TLabel.Create(WizardForm);
            DescLabelFinPage.Parent := WizardForm.FinishedPage;            
            DescLabelFinPage.Color := clRed;
            DescLabelFinPage.Top := 250;
            DescLabelFinPage.Left := 0;

          end;

function ShouldSkipPage(PageID: Integer): Boolean;
         begin
  
           Result := False;
  
           if PageID = MySelectDirPage.ID then    
             Result := not WizardIsComponentSelected('GEP');

         end;

procedure CurPageChanged(CurPageID: Integer);

          begin

            DescLabelSelDirPage.Caption := ''

            if (CurPageID = wpSelectComponents) and not CompPageVisited then
              begin
                CompPageVisited := True;
              end;

          end;


installation inno-setup admin
1个回答
0
投票

您正在安装和运行的文件是

{#gei}
,其定义为
#define gei "Setup 0.0.0.exe"

UAC 具有安装程序检测,可将您的应用程序识别为安装程序,因为

文件名包含“安装”、“设置”或“更新”等关键字。

从而显示 UAC 对话框,要求提供凭据。

如果应用程序在没有权限的情况下也能运行,请重命名该应用程序。

© www.soinside.com 2019 - 2024. All rights reserved.