9

By following this: https://productforums.google.com/forum/#!topic/chrome/8XnSOnhLBzA

  • Went to http://ninite.com/chrome/ to get their chrome installer (but that's not helping me cause I need to at the end open a specific Website once the Google Chrome is installed)

  • Now I am trying to use Inno Setup myself, to make sure I have almost same as Ninite

  • once Inno Setup is done with Google Chrome installation, how can I make sure to open www.stackoverflow.com with Google Chrome?

Here is my code of Inno Setup, not doing correctly in point 3:

  1. installing Google Chrome

  2. after install executing Google Chrome

  3. BUT how can I tell the Google Chrome - execute that first link: www.stackoverflow.com?

; 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 MyAppExeName "ChromeSetup (1).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={{FCF7940A-D96F-4A7A-9C69-C9DFE8BB308A}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir=C:\Users\sun\Desktop\Nieuwe map
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

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

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\sun\Downloads\ChromeSetup (1).exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 1
    You can simply execute `chrome.exe www.stackoverflow.com`, but you must know the Chrome path, which you should know anyway to avoid installing another Chrome instance to the same user. – TLama Mar 20 '14 at 14:44
  • @TLama: I have to make sure 1) Chrome is installed if not exist 2) i have to after install of Chrome execute the first page to stackoverflow.com 3) if already Chrome exist, installer should do nothing but execute chrome.exe www.stackoverflow.com only . I am unable to make that with innosetup. –  Mar 20 '14 at 14:45
  • 1
    And about the Chrome installer, I would rather [`take the one`](https://www.google.com/intl/cs/chrome/browser/?platform=win&standalone=1) from the official resource (notice the `standalone=1` parameter in that link URL). – TLama Mar 20 '14 at 20:10

1 Answers1

12

The following might work, since the registry key I'm referring to, is described in the official docs for the Chrome installer. There is one registry key which directly contains a path to the chrome.exe file so it's IMHO the best choice to get the Chrome app. file name. It is this key:

<root>\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe

Where the <root> is either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER registry root depending on whether the Chrome has been installed for the current user or globally for the whole system.

In the following script I'm using the above key not only for getting the Chrome app. file name, but even for determining if the Chrome is installed:

[Files]
Source: "chrome_installer.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall

[Run]
Filename: "{tmp}\chrome_installer.exe"; Check: not IsChromeInstalled
Filename: "{code:GetChromeFileName}"; Parameters: "www.stackoverflow.com"; \
    Check: IsChromeInstalled

[Code]
const
  ChromeAppRegKey = 'Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe';

function IsChromeInstalled: Boolean;
begin
  { check if there's the Chrome app registration entry under the HKCU, or }
  { HKLM root key, return the result }
  Result := RegKeyExists(HKEY_CURRENT_USER, ChromeAppRegKey) or
    RegKeyExists(HKEY_LOCAL_MACHINE, ChromeAppRegKey);
end;

function GetChromeFileName(Value: string): string;
var
  S: string;
begin
  { initialize returned value to an empty string }
  Result := '';
  { first attempt to read the Chrome app file name from the HKCU root key; }
  { if that fails, try to read the same from HKLM; if any of that succeed, }
  { return the obtained registry value }
  if RegQueryStringValue(HKEY_CURRENT_USER, ChromeAppRegKey, '', S) or
    RegQueryStringValue(HKEY_LOCAL_MACHINE, ChromeAppRegKey, '', S)
  then
    Result := S;
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
TLama
  • 75,147
  • 17
  • 214
  • 392
  • +1 - Thank you very much. Genius, you are the super star. It works so great. –  Mar 20 '14 at 21:38
  • 1
    You're welcome! :) Actually, it's been quite a luck that it's officially documented and that they are using a registry key directly pointing to the application file. How I wish that would be common for all applications (mostly those from Microsoft, whose are having a big mess in product registering). – TLama Mar 20 '14 at 21:46
  • Is there anyway to enable the chrome extension by default ? – Trang D Sep 29 '20 at 06:36