2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

innoSetupでプログラムの配布ファイルを1つにまとめる方法

Last updated at Posted at 2021-05-08

innoSetupというソフトを使って、インストーラーを作成し、Windows上での配布ファイルを1つにまとめる方法について以下のYouTube動画で解説しました。
https://youtu.be/dUl2f-EkO48

まずは以下のページよりinnosetup-6.1.2.exeをダウンロードします。(2021年5月時点)
Download Siteという項目で、USというのを選択してあげると良いと思います。
https://jrsoftware.org/isdl.php

innoSetupのインストールが終わると、以下のようなソフトが起動します。
起動したら、コードを入力するフィールドがあるので、そこにコードを入力してあげます。コードを入力し終わったら、緑色の実行ボタンを押してあげるとインストーラーが作成されます。
innoSetup.JPG

動画内で実際に使用しているコードが以下の通りです。
コメントで解説するのは大変なので、詳しい解説は動画でご覧ください。

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

#define MyAppName "iFacialMocap" //書き換えるポイント① アプリ名を変更
#define MyAppVersion "1.12" //書き換えるポイント② アプリのバージョンを変更
#define MyAppPublisher "Yasushi Emoto" //書き換えるポイント③ 自分の名前を入れる
#define MyAppURL "https://ifacialmocap.com/" //書き換えるポイント④ アプリのURL
#define MyAppExeName "iFacialMocap.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={{xxxxx-xxxxx-xxxx-xxx-xxxxxxx}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=C:\Users\emoto\Desktop
OutputBaseFilename=iFacialMocapSetup
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Code]

/////////////////////////////////////////////////////////////////////
function GetUninstallString(): String;
var
  sUnInstPath: String;
  sUnInstallString: String;
begin
  sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
  sUnInstallString := '';
  if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
    RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
  Result := sUnInstallString;
end;


/////////////////////////////////////////////////////////////////////
function IsUpgrade(): Boolean;
begin
  Result := (GetUninstallString() <> '');
end;


/////////////////////////////////////////////////////////////////////
function UnInstallOldVersion(): Integer;
var
  sUnInstallString: String;
  iResultCode: Integer;
begin
// Return Values:
// 1 - uninstall string is empty
// 2 - error executing the UnInstallString
// 3 - successfully executed the UnInstallString

  // default return value
  Result := 0;

  // get the uninstall string of the old app
  sUnInstallString := GetUninstallString();
  if sUnInstallString <> '' then begin
    sUnInstallString := RemoveQuotes(sUnInstallString);
    if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
      Result := 3
    else
      Result := 2;
  end else
    Result := 1;
end;

/////////////////////////////////////////////////////////////////////
procedure CurStepChanged(CurStep: TSetupStep);
begin
  if (CurStep=ssInstall) then
  begin
    if (IsUpgrade()) then
    begin
      UnInstallOldVersion();
    end;
  end;
end;

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.isl"
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
Name: "icelandic"; MessagesFile: "compiler:Languages\Icelandic.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
Name: "slovak"; MessagesFile: "compiler:Languages\Slovak.isl"
Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"

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

[Files]
//書き換えるポイント⑦ 実行ファイルのある場所を指定
Source: "C:\Users\emoto\Documents\hold\iFacialMocapDevelop\dist\iFacialMocap\iFacialMocap.exe"; DestDir: "{app}"; Flags: ignoreversion

//書き換えるポイント⑧ ユーザーに配布したいデータのルートフォルダを指定
Source: "C:\Users\emoto\Documents\hold\iFacialMocapDevelop\dist\iFacialMocap\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

//書き換えるポイント⑨ ユーザーに配布したいデータのフォルダが他にもあったら指定
Source: "C:\Users\emoto\Documents\hold\iFacialMocapDevelop\iFacial_connectScripts\*"; DestDir: "{app}\iFacial_connectScripts"; Flags: ignoreversion recursesubdirs createallsubdirs

//書き換えるポイント⑩ ユーザーに配布したいファイルが他にもあったら指定
Source: "C:\Users\emoto\Documents\hold\iFacialMocapDevelop\Acknowledgments.txt"; DestDir: "{app}\Acknowledgments.txt"; Flags: ignoreversion recursesubdirs

//書き換えるポイント⑪ WindowsのAppDataフォルダにコピーしたいフォルダがあれば指定                                          
Source: "C:\Users\emoto\Documents\hold\iFacialMocapDevelop\unity_standaloneData\*";DestDir: "{userappdata}\iFacialMocap\unity_standaloneData";Flags: ignoreversion recursesubdirs createallsubdirs

//書き換えるポイント⑫ ユーザーに配布したいフォルダで、アンインストール後にも削除したくない(ユーザー設定などの)フォルダがあれば指定してAppDataフォルダにコピー
Source: "C:\Users\emoto\Documents\hold\iFacialMocapDevelop\settingFiles\*"; \
    DestDir: "{userappdata}\iFacialMocap\settingFiles"; \
    Flags: ignoreversion recursesubdirs createallsubdirs \
           onlyifdoesntexist uninsneveruninstall
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

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

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

.
.
.
.
.
.
.
.
.
.

.

.
.
.

.
.

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?