Inno Setup Compiler:如何使用给定的URL自动启动默认浏览器? [英] Inno Setup Compiler: How to auto start the default browser with given url?

查看:100
本文介绍了Inno Setup Compiler:如何使用给定的URL自动启动默认浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to start my default browser (chrome) with a given url:

http://localhost/folder

通过将inno setup compiler用于windows

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

after the installer finishes, i run the wamp manager

要达到此目的,我必须在run部分中写些什么?

what do I have to write in the run section to achive this?

ps:

app应该安装一个wamp便携式集合(Apache Web服务器,mysql,php,phpmyadmin)

this app should install a wamp portable collection (apache web server, mysql, php, phpmyadmin)

安装程序完成后,应启动wamp manager,等待最大5 seconds,然后应使用给定的URL

when the installer finishes, it should start the wamp manager, wait for max 5 seconds, and then it should open de default browser with a given URL

; 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

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

after hours of research, this is what i have:

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

and this is not the best version, but this is what i want

; 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

推荐答案

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

To load an URL at the end of the installation in the user's default browser, simply do this:

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

如果您希望默认情况下取消选中它,则还要添加unchecked标志.

If you want it to be unticked by default, also add the unchecked flag.

这篇关于Inno Setup Compiler:如何使用给定的URL自动启动默认浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆