2

我正在尝试使用给定的 url 启动我的默认浏览器(chrome):

http://localhost/folder

通过使用inno setup compilerforwindows

安装程序完成后,我运行 wamp 管理器

我必须在该run部分写什么才能实现这一目标?

ps:

app应该安装一个 wamp 便携式集合(apache web 服务器、mysql、php、phpmyadmin)

当安装程序完成时,它应该启动wamp manager,等待 max 5 seconds,然后它应该default browser用给定的打开 deURL

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

#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define WM "Wamp Manager"
#define Exewampmanager "wampmanager.exe"

[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={{0BA2F7BC-1EFD-4BF5-A06B-28E003B02760}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\cow1
DefaultGroupName=My Program1
AllowNoIcons=yes
LicenseFile=D:\New Text Document.txt
InfoBeforeFile=D:\New Text Document.txt
InfoAfterFile=D:\New Text Document.txt
OutputDir=D:\inno
OutputBaseFilename=setup2
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "C:\wamp\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"

[Run]
Filename: "{app}\{#Exewampmanager}"; Description: "{cm:LaunchProgram,{#StringChange(WM, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

经过数小时的研究,这就是我所拥有的:

这不是最好的版本,但这就是我想要的

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

#define MyAppName "cow1"
#define MyAppVersion "1.5"
#define MyAppPublisher "my cow, Inc."
#define MyAppURL "http://www.example.com/"
#define WM "Wamp Manager"
#define Exewampmanager "wampmanager.exe"
#define Chrome "Chrome"
#define ExeChrome "chrome.exe"

[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={{0BA2F7BC-1EFD-4BF5-A06B-28E003B02760}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\cow1
DefaultGroupName=My Program1
AllowNoIcons=yes
LicenseFile=D:\New Text Document.txt
InfoBeforeFile=D:\New Text Document.txt
InfoAfterFile=D:\New Text Document.txt
OutputDir=D:\inno
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[code]
#IFDEF UNICODE
  #DEFINE AW "W"
#ELSE
  #DEFINE AW "A"
#ENDIF

const
  WAIT_TIMEOUT = $00000102;
  SEE_MASK_NOCLOSEPROCESS = $00000040;

type
  TShellExecuteInfo = record
    cbSize: DWORD;
    fMask: Cardinal;
    Wnd: HWND;
    lpVerb: string;
    lpFile: string;
    lpParameters: string;
    lpDirectory: string;
    nShow: Integer;
    hInstApp: THandle;    
    lpIDList: DWORD;
    lpClass: string;
    hkeyClass: THandle;
    dwHotKey: DWORD;
    hMonitor: THandle;
    hProcess: THandle;
  end;

function ShellExecuteEx(var lpExecInfo: TShellExecuteInfo): BOOL; 
  external 'ShellExecuteEx{#AW}@shell32.dll stdcall';
function WaitForSingleObject(hHandle: THandle; dwMilliseconds: DWORD): DWORD; 
  external 'WaitForSingleObject@kernel32.dll stdcall';
function TerminateProcess(hProcess: THandle; uExitCode: UINT): BOOL;
  external 'TerminateProcess@kernel32.dll stdcall';

function NextButtonClick(CurPageID: Integer): Boolean;
var
  ExecInfo: TShellExecuteInfo;
  ExecInfoBrowser: TShellExecuteInfo;
begin
  Result := True;

  if CurPageID = wpFinished then
  begin
    ExecInfo.cbSize := SizeOf(ExecInfo);
    ExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS;
    ExecInfo.Wnd := 0;
    ExecInfo.lpFile := ExpandConstant('{app}') + '\{#Exewampmanager}';
    ExecInfo.nShow := SW_HIDE;
    if ShellExecuteEx(ExecInfo) then
      begin
        if WaitForSingleObject(ExecInfo.hProcess, 7000) = WAIT_TIMEOUT then
          begin
               ExecInfoBrowser.cbSize := SizeOf(ExecInfo);
               ExecInfoBrowser.fMask := SEE_MASK_NOCLOSEPROCESS;
               ExecInfoBrowser.Wnd := 0;
               ExecInfoBrowser.lpFile := 'http://localhost/cow';
               ExecInfoBrowser.nShow := SW_HIDE;
               ShellExecuteEx(ExecInfoBrowser);
          end;
      end;
  end;
end;

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

;[Files]
;Source: "C:\wamp\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"

[Run]
;Filename: "{app}\{#Exewampmanager}"; Description: "{cm:LaunchProgram,{#StringChange(WM, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
4

1 回答 1

6

要在安装结束时在用户的默认浏览器中加载 URL,只需执行以下操作:

[Run]
Filename: http://whatever.com/something; Description: "Visit website"; Flags: postinstall shellexec

如果您希望它在默认情况下不勾选,还请添加unchecked标志。

于 2013-10-10T20:55:54.663 回答