2016-08-08 2 views
0

코드가 끔찍한 경우 사과드립니다. 이 오류 메시지로 실행하고 있습니다 :"드라이버 [...] 또는 UNC 경로와 함께 전체 경로를 입력해야합니다 ..."inno 설치 오류 메시지

enter image description here

설치 프로그램은 현재 관리자가 아닌 사용자가 다음 죽이기로 시작하고 파일 복사 시작 바로 전에 관리자로 자신을 다시 시작합니다. 오류 메시지는 '등록'설치가 선택된 경우에만 나타납니다.

설치 위치에 최상위 드라이브를 입력 한 경우 발생합니다. 네트워크 공유에 폴더를 입력하면 다른 오류 (다른 권한 문제)가 발생하고 C : \ 드라이브 (C : \ xyz에서와 같이)에 폴더를 입력하면 정상적으로 작동합니다. 그것이 나오는 것에 따라

#define MyAppName "O" 
#define MyAppVersion "0.0" 

[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.) 
AppId={{9BB6F4FD-5530-4043-BD9E-A405BAEDDDFF}} 
AppName={#MyAppName} 
AppVersion={#MyAppVersion} 
DefaultDirName={sd}\{#MyAppName} 
DisableDirPage=yes 
AllowNoIcons=yes 
OutputDir={desktop} 
OutputBaseFilename=dummy 
Compression=lzma 
SolidCompression=yes 

PrivilegesRequired=lowest 

[Types] 
Name: "server"; Description: "Odin Server Install" 
Name: "client"; Description: "Odin Register/Workstation Install" 

[Components] 
Name: "data_shared_exe"; Description: "Core apps installed"; Types: server; 
Name: "C_Odin"; Description: "Database stuff"; Types: server client; 
Name: "shortcuts"; Description: "Shortcuts to Odin apps"; Types: server client; 

[Code] 

var 
    SelectOdinSharePage: TInputDirWizardPage; 
    SelectOdinInstallPage: TInputDirWizardPage; 

    Elevated: Boolean; 
    InstallType: Integer; 
    DirParam: string; 

type 
    HINSTANCE = THandle; 

// Privilege Escalation code 
// Inspired by/Courtesy of http://stackoverflow.com/questions/21556853/make-inno-setup-installer-request-privileges-elevation-only-when-needed 
procedure ExitProcess(uExitCode: UINT); 
    external '[email protected] stdcall'; 
function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string; 
    lpParameters: string; lpDirectory: string; nShowCmd: Integer): HINSTANCE; 
    external '[email protected] stdcall'; 

function IsServerInstall(): Boolean; 
begin 
    Result := (InstallType=0) 
end; 

function CmdLineParamExists(const Value: string): Boolean; 
var 
    I: Integer; 
begin 
    Result := False; 
    for I := 1 to ParamCount do 
    if CompareText(ParamStr(I), Value) = 0 then 
    begin 
     Result := True; 
     Exit; 
    end; 
end; 

function CmdLineParamReadInt(const Value: string): integer; 
var 
    I: Integer; 
begin 
    Result := -1; 
    for I := 1 to ParamCount do 
    if Pos(Value, ParamStr(I)) = 1 then 
    begin 
     Result := StrToInt(Copy(ParamStr(I), Length(Value)+2, 1)); 
     //MsgBox(Format('ReadInt: %s', [Copy(ParamStr(I), Length(Value)+2, 1)]), mbInformation, MB_OK); 
     Exit; 
    end; 
end; 

function CmdLineParamReadStr(const Value: string): string; 
var 
    I: Integer; 
begin 
    Result := ''; 
    for I := 1 to ParamCount do 
    if Pos(Value, ParamStr(I)) = 1 then 
    begin 
     Result := Copy(ParamStr(I), Length(Value)+2, Length(ParamStr(I))-Length(Value)-1); 
     //MsgBox(Format('ReadStr: %s',[Result]), mbInformation, MB_OK) 
     Exit; 
    end; 
end; 

procedure OnTypeChange(Sender: TObject); 
begin 
    // set the item index in hidden TypesCombo 
    WizardForm.TypesCombo.ItemIndex := TNewRadioButton(Sender).Tag; 
    InstallType := TNewRadioButton(Sender).Tag; 
    // notify TypesCombo about the selection change 
    WizardForm.TypesCombo.OnChange(nil); 
end; 

procedure InitializeWizard(); 
var 
    I: Integer; 
    RadioButton: TNewRadioButton; 
begin 
    // By default, InstallType is 1 ('Register') 
    InstallType := 1; 

    // Privilege escalation parameters 
    Elevated := CmdLineParamExists('/ELEVATE'); 
    if Elevated then 
    begin 
    InstallType := CmdLineParamReadInt('/INSTALLTYPE'); 
    DirParam := CmdLineParamReadStr('/DIR'); 
    //MsgBox(Format('DirParam: %s', [DirParam]), mbInformation, MB_OK); 
    end; 

    for I := 0 to WizardForm.TypesCombo.Items.Count - 1 do 
    begin 
    // create radio button and set the basic properties 
    RadioButton := TNewRadioButton.Create(WizardForm); 
    RadioButton.Parent := WizardForm.SelectComponentsPage; 
    RadioButton.Left := WizardForm.TypesCombo.Left; 
    RadioButton.Top := WizardForm.TypesCombo.Top + I * RadioButton.Height; 
    RadioButton.Width := WizardForm.TypesCombo.Width; 
    // the Tag property substitutes the index property 
    RadioButton.Tag := I; 
    RadioButton.TabOrder := I;  
    RadioButton.OnClick := @OnTypeChange; 
    // check just the first item 
    RadioButton.Checked := I = InstallType; 
    RadioButton.Caption := WizardForm.TypesCombo.Items[I]; 
    end; 
    // hide the TypesCombo combo box 
    WizardForm.TypesCombo.Visible := False; 

    SelectOdinSharePage := CreateInputDirPage(wpSelectComponents, 
    'Select Odin Exe''s directory', 'Where are the Odin exe''s located?', 
    'The Odin exe''s are usually located on the Odin Network Share under "exe" or "exes". ' + 
    'Once you have found this directory, click Next. If you would like to select a different folder, click Browse.', 
    False, 'New Folder'); 
    SelectOdinSharePage.Add(''); 
    SelectOdinSharePage.Values[0] := 'O:'; 

    SelectOdinInstallPage := CreateInputDirPage(wpSelectComponents, 
    'Select Odin Install directory', 'Select where to install Odin core apps', 
    'To continue, click Next. If you would like to select a different folder, click Browse.', 
    False, 'New Folder'); 
    SelectOdinInstallPage.Add(''); 
    SelectOdinInstallPage.Values[0] := 'C:\Program Files (x86)\Odin'; 

    if Elevated then 
    begin 
    if IsServerInstall() then SelectOdinInstallPage.Values[0] := DirParam; 
    if not IsServerInstall() then SelectOdinSharePage.Values[0] := DirParam; 
    end; 
end; 

function ShouldSkipPage(PageID: Integer): Boolean; 
begin 
    Result := False; 
    if ((PageID=100) and IsServerInstall()) then Result := True; 
    if ((PageID=101) and not IsServerInstall()) then Result := True; 

    if Elevated then 
    begin 
    if IsServerInstall() then 
    begin 
     if ((PageID=7) or (PageID=101)) then Result := True; 
    end; 
    if InstallType=1 then 
    begin 
     if ((PageID=7) or (PageID=100)) then Result := True; 
    end; 
    end; 
end; 

function NextButtonClick(CurPageID: Integer): Boolean; 
var 
    Params: string; 
    RetVal: HINSTANCE; 
begin 
    Result := True; 
    //MsgBox(Format('Is Server Install: %d', [WizardForm.TypesCombo.ItemIndex]), mbInformation, MB_OK); 
    if (CurPageID=101) and IsServerInstall() then 
    begin 
    Params := ExpandConstant('/DIR="' + SelectOdinInstallPage.Values[0] + '" /ELEVATE /INSTALLTYPE=0'); 
    RetVal := ShellExecute(WizardForm.Handle, 'runas', 
     ExpandConstant('{srcexe}'), Params, '', SW_SHOW); 
    if RetVal > 32 then 
    begin 
     ExitProcess(0); 
    end 
    else 
     MsgBox('Administrative privilege escalation failed. Install aborted. Contact Odin Support.', mbInformation, MB_OK); 
     ExitProcess(0); 
    end; 
    if (CurPageID=100) and (not IsServerInstall()) then 
    begin 
    Params := ExpandConstant('/DIR="' + SelectOdinSharePage.Values[0] + '" /ELEVATE /INSTALLTYPE=1'); 

    RetVal := ShellExecute(WizardForm.Handle, 'runas', 
     ExpandConstant('{srcexe}'), Params, '', SW_SHOW); 
    if RetVal > 32 then 
    begin 
     ExitProcess(0); 
    end 
    else 
     MsgBox('Administrative privilege escalation failed. Install aborted. Contact Odin Support.', mbInformation, MB_OK); 
     ExitProcess(0); 
    end; 
end; 

답변

0

이 문제는이 코드 섹션에서 라인

if (CurPageID=100) and (not IsServerInstall()) then 
    begin 
    Params := ExpandConstant('/DIR="' + SelectOdinSharePage.Values[0] + '" /ELEVATE /INSTALLTYPE=1'); 

    RetVal := ShellExecute(WizardForm.Handle, 'runas', 
     ExpandConstant('{srcexe}'), Params, '', SW_SHOW); 

자리 잡고, 실행 프로그램은 관리자 권한으로 발사 재. PARAMS SECTION에서 '/ DIR'옵션은 Inno Setup 옵션이며 기본 InstallDirectory를 덮어 씁니다. 최상위 수준의 드라이브가 아닌 'C : \'또는 'O : \'가 아닌 'C : \ xyz'로 설정되어야합니다.

변경된 경우 위의 프로그램 스텁이 정상적으로 작동합니다.

관련 문제