Inno Setup使用

Inno Setup是一個開源的安裝包打包軟件,下載地址是:http://www.jrsoftware.org/isdl.phpphp

 

使用引導界面建立一個安裝包打包windows

 

 

配置參考官方文檔:http://www.jrsoftware.org/ishelp/index.php服務器

 

 

個人配置app

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


[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={{F6C5E189-481C-4249-96B0-D30C7E6CB320}
;應用名稱
AppName=MES Monitoring Client
;應用版本號
AppVersion=1.0
;AppVerName=MES Monitoring Client 1.0
;應用發佈方
AppPublisher=廣東翠峯機器人股份有限公司
;安裝目錄名稱
DefaultDirName={pf64}\MES-Monitoring-Client
;安裝目錄不可選擇
DisableDirPage=auto
;安裝後不會出如今開始應用菜單
DisableProgramGroupPage=no
;安裝包文件名
OutputBaseFilename=MES-MonitoringClient-Setup
;壓縮包
Compression=lzma
SolidCompression=yes
;安裝包圖標文件
SetupIconFile=D:\document\mes\setup.ico
;安裝時須要提供管理員權限
PrivilegesRequired=admin
;許可文件
LicenseFile=D:\report\wes\MES-MonitoringClient\SetupScript\License.txt


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

[Tasks]
;桌面增長快捷圖標
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
;快捷方式
Name: quicklaunchicon; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:CreateQuickLaunchIcon}"; Flags: unchecked


[Files]
;安裝文件

;Client的文件夾
;Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\*"; DestDir: "{app}\Client"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\DnsClient.dll"; DestDir: "{app}\Client"; Flags: ignoreversion;  Components: Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\DnsClient.xml"; DestDir: "{app}\Client"; Flags: ignoreversion;  Components: Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\LiveCharts.dll"; DestDir: "{app}\Client"; Flags: ignoreversion;  Components: Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\LiveCharts.pdb"; DestDir: "{app}\Client"; Flags: ignoreversion;  Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\LiveCharts.WinForms.dll"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\LiveCharts.WinForms.pdb"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\LiveCharts.WinForms.xml"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\LiveCharts.Wpf.dll"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\LiveCharts.Wpf.pdb"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\LiveCharts.Wpf.xml"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client 
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\LiveCharts.xml"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\MES-MonitoringClient.exe"; DestDir: "{app}\Client"; Flags: ignoreversion;  Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\MES-MonitoringClient.exe.config"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\MES-MonitoringClient.pdb"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\MongoDB.Bson.dll"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\MongoDB.Bson.xml"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\MongoDB.Driver.Core.dll"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\MongoDB.Driver.Core.xml"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\MongoDB.Driver.dll"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\MongoDB.Driver.xml"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\RabbitMQ.Client.dll"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\RabbitMQ.Client.xml"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\System.Buffers.dll"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringClient\bin\Debug\System.Runtime.InteropServices.RuntimeInformation.dll"; DestDir: "{app}\Client"; Flags: ignoreversion; Components:Client
;Service的文件夾
;Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\*"; DestDir: "{app}\Service"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\DnsClient.dll"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\DnsClient.xml"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\MES-MonitoringService.exe"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\MES-MonitoringService.exe.config"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\MES-MonitoringService.pdb"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\MongoDB.Bson.dll"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\MongoDB.Bson.xml"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\MongoDB.Driver.Core.dll"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\MongoDB.Driver.Core.xml"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\MongoDB.Driver.dll"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\MongoDB.Driver.xml"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\Newtonsoft.Json.dll"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\Newtonsoft.Json.pdb"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\Newtonsoft.Json.xml"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\RabbitMQ.Client.dll"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\RabbitMQ.Client.xml"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\System.Buffers.dll"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\System.Runtime.InteropServices.RuntimeInformation.dll"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\Topshelf.dll"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\Topshelf.xml"; DestDir: "{app}\Service"; Flags: ignoreversion; Components:Service
;若是有日誌,則複製日誌,若是沒有,則不復制
Source: "D:\report\wes\MES-MonitoringClient\MES-MonitoringService\bin\Debug\log.log"; DestDir: "{app}\Service"; Flags: ignoreversion skipifsourcedoesntexist; Components:Service 

;NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
;桌面圖標
Name: "{commondesktop}\MES Monitoring Client"; Filename: "{app}\Client\MES-MonitoringClient.exe"; Tasks: desktopicon
;在「開始」--「程序」裏,添加一個開始的快捷方式
Name: "{commonprograms}\MES Client\MES Monitoring Client"; Filename: "{app}\Client\MES-MonitoringClient.exe"
;在「開始」--「程序」裏,添加一個卸載的快捷方式
Name: "{commonprograms}\MES Client\Uninstall Application"; Filename: "{uninstallexe}"

[Registry]
;開機啓動
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "MES Monitoring Client"; ValueData: """{app}\Client\MES-MonitoringClient.exe"""; Flags: uninsdeletevalue


[run]
;兩種方法均可以安裝服務,上面的能夠將服務安裝好,但不能直接運行
;Filename: {sys}\sc.exe; Parameters: "create MESUploadDataService start= auto binPath= ""{app}\Service\MES-MonitoringService.exe""" ; Flags: runhidden
;如下的方式能夠直接運行,其中有Components:Service;當選中了服務纔會安裝服務      
;Flags:postinstall點擊完成後,纔會進行服務的安裝,由於在處理RabbitMQ的服務器參數時,不會直接替換參數的
Filename: "{app}\Service\MES-MonitoringService.exe"; Description:"安裝並運行MES客戶端數據上傳服務"; Parameters: " install start"; Components:Service; Flags:postinstall runhidden hidewizard;
;安裝完成後啓動應用
Filename: "{app}\Client\MES-MonitoringClient.exe"; Description: "{cm:LaunchProgram,MES Monitoring Client}"; Flags:postinstall skipifsilent unchecked      


[UninstallRun]
;卸載時,中止服務並刪除服務
Filename: {sys}\sc.exe; Parameters: "stop MESUploadDataService" ; Flags: runhidden; Components:Service
Filename: {sys}\sc.exe; Parameters: "delete MESUploadDataService" ; Flags: runhidden; Components:Service

[Messages]
;安裝時,windows任務欄提示標題
SetupAppTitle=MES Monitoring Client Setup
;安裝時,安裝引導標題
SetupWindowTitle=MES Monitoring Client Setup
;在界面左下角加文字
BeveledLabel=廣東翠峯機器人股份有限公司
;卸載對話框說明
ConfirmUninstall=您真的想要從電腦中卸載 %1 嗎?%n%n按 [是] 則徹底刪除 %1 以及它的全部組件;%n按 [否]則讓軟件繼續留在您的電腦上.


[Types]
Name: "normaltype"; Description: "Normal Setup"
Name: "custom";     Description: "Custom Installation"; Flags: iscustom

[Components]
Name: "Client";     Description: "應用界面";  Types: normaltype custom
Name: "Service";    Description: "後臺服務";  Types: normaltype custom


[Code]
var CustomPage: TInputQueryWizardPage;

//設置Rabbit Server Host
function NextButtonClick(CurPage: Integer): Boolean;
var
  str: string;
  strFilename: string;
  HostEmptyChecked: Boolean;

begin
  Result := true;  

  if CurPage = wpSelectComponents then
   begin
      // if IsComponentSelected('full') then
      if (CustomPage = nil) then
      begin
        // Set Custom Page initial values
        CustomPage := CreateInputQueryPage(wpSelectComponents, 
        'RabbitMQ 配置', 'MES服務信息配置', 
        '請輸入Rabbit Server Host地址,而後點擊 下一步 按鈕');
        CustomPage.Add('Server Host:', False);        
        CustomPage.Values[0] := '172.19.0.153';        
        //CustomPage.Values[0] := '';        
      end;
   end;

  if CurPage = wpFinished then
   begin
      //找到文件地下
      strFilename := ExpandConstant('{app}\Service\MES-MonitoringService.exe.config');

      if FileExists(strFilename) then
      begin
        // Replace the values in the .config file and save it
        LoadStringFromFile(strFilename, str);
        //經過替換完整的key,找到全部<add key="RabbitMQServerHostName" value="localhost"/>內容並替換成如下值
        StringChangeEx(str, '<add key="RabbitMQServerHostName" value="localhost"/>','<add key="RabbitMQServerHostName" value="'+CustomPage.Values[0]+'"/>', True);        
        SaveStringToFile(strFilename, str, False);             
      end;
   end;
end;

[Code]
//設置界面文字顏色
procedure InitializeWizard(); 
begin 
  //WizardForm.WELCOMELABEL1.Font.Color:= clGreen;//設置開始安裝頁面第一段文字的顏色爲綠色 
  //WizardForm.WELCOMELABEL2.Font.Color:= clOlive;//設置開始安裝頁面第二段文字的顏色爲橄欖綠 
  //WizardForm.PAGENAMELABEL.Font.Color:= clRed;//設置許可協議頁面第一段文字的顏色爲紅色 
  //WizardForm.PAGEDESCRIPTIONLABEL.Font.Color:= clBlue; //設置許可協議頁面第二段文字的顏色爲藍色 
  WizardForm.MainPanel.Color:= clWhite;//設置窗格的顏色爲白色
 
end;


//卸載後打開網址
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
  ErrorCode: Integer;
begin
  case CurUninstallStep of
    usUninstall:
      begin        
        // 正在卸載
      end;
    usPostUninstall:
      begin
        //卸載完成       
        //ShellExec('open', 'http://www.cfmm.com.cn/', '', '', SW_SHOW, ewNoWait, ErrorCode)
      end;
  end;
end;
View Code
相關文章
相關標籤/搜索