2016-07-27 5 views
2

사용자가 응용 프로그램을 설치할 위치를 지정할 수있는 설치 스크립트가 있습니다. [Code] 블록 내에 파스칼 스크립트 형식입니다.Inno 설치 자동 설치를 위해 파일 (.inf)에서 사용자 지정 설치 설정의 기본값을로드하십시오.

var 
    SelectUsersPage: TInputOptionWizardPage; 
    IsUpgrade : Boolean; 
    UpgradePage: TOutputMsgWizardPage; 

procedure InitializeWizard(); 
var 
    AlreadyInstalledPath: String; 
begin 
    { Determine if it is an upgrade... } 
    { Read from registry to know if this is a fresh install or an upgrade } 
    if RegQueryStringValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppId}_is1', 'Inno Setup: App Path', AlreadyInstalledPath) then 
    begin 
     { So, this is an upgrade set target directory as installed before } 
     WizardForm.DirEdit.Text := AlreadyInstalledPath; 
     { and skip SelectUsersPage } 
     IsUpgrade := True; 

     { Create a page to be viewed instead of Ready To Install } 
     UpgradePage := CreateOutputMsgPage(wpReady, 
     'Ready To Upgrade', 'Setup is now ready to upgrade {#MyAppName} on your computer.', 
     'Click Upgrade to continue, or click Back if you want to review or change any settings.'); 
    end 
    else 
    begin 
     IsUpgrade:= False; 
    end; 

    { Create a page to select between "Just Me" or "All Users" } 
    SelectUsersPage := CreateInputOptionPage(wpLicense, 
    'Select Users', 'For which users do you want to install the application?', 
    'Select whether you want to install the library for yourself or for all users of this computer. Click next to continue.', 
    True, False); 

    { Add items } 
    SelectUsersPage.Add('All users'); 
    SelectUsersPage.Add('Just me'); 

    { Set initial values (optional) } 
    SelectUsersPage.Values[0] := False; 
    SelectUsersPage.Values[1] := True; 
end; 

그래서 자동 설치를 어떻게 지원할 수 있습니까? 사용자가 /SILENT 또는 /VERYSILENT을 호출하면 설치 프로그램의 기본값은 SelectUsersPage.Values[1]이며 Just Me입니다. 응답 파일을 제공하여 설치 디렉토리를 변경하려는 사용자를 지원하도록 돕고 싶습니다.

나는이 코드를 모두 개발하지 않았으며 Pascal을 가진 초보자입니다.

감사합니다.

+0

이 기본값을 당신이 기본값을 물어 무엇을. 기본값을 변경하십시오. –

+0

왜 이것을 downvote하셨습니까? 마법사 중에 기본값을 변경하는 방법을 묻지 않습니다. 사용자가 제공 할 수있는 자동 설치 매개 변수 파일을 처리하는 방법을 묻습니다. 앱을 설치할 위치를 제어 할 수 있습니다. –

+0

음, 정확히 이것 때문입니다. 네가 원하는 걸 우리에게 설명하게하기 위해서. 문제는이 정확한 정보가 누락되었습니다. +1하세요. –

답변

1

/SAVEINF에 의해 생성 된 .inf 파일에 맞춤 키 (예 : Users)를 추가 할 수 있습니다.

그런 다음 설치 프로그램에서 /LOADINF command-line argument를 조회하고, 키를 읽고 따라 행동 :

procedure InitializeWizard(); 
var 
    InfFile: string; 
    I: Integer; 
    UsersDefault: Integer; 
begin 
    ... 

    InfFile := ExpandConstant('{param:LOADINF}'); 

    UsersDefault := 0; 

    if InfFile <> '' then 
    begin 
    Log(Format('Reading INF file %s', [InfFile])); 
    UsersDefault := 
     GetIniInt('Setup', 'Users', UsersDefault, 0, 0, ExpandFileName(InfFile)); 
    Log(Format('Read default "Users" selection %d', [UsersDefault])); 
    end 
    else 
    begin 
    Log('No INF file'); 
    end; 

    SelectUsersPage.Values[UsersDefault] := True; 
end; 
+0

감사합니다. 처음에는 GetINInt() 함수를 찾을 때까지 INF 파일에서 키와 그 값을 저장할 필요가 있었고 [Setup] 섹션에서 Users 키를 만들어야한다는 것을 알았습니다. 'IsUpgrade'가 True로 설정되었는지 확인하기 위해 추가 코드를 추가해야합니다. 그러면 제공된 코드 블록이 업그레이드 중에 실행되지 않습니다. 당신의 도움을 주셔서 대단히 감사합니다! –