一個比較完整的Inno Setup 安裝指令碼(轉)

來源:互聯網
上載者:User

標籤:

一個比較完整的Inno Setup 安裝指令碼,增加了對ini檔案設定的功能,一個安裝包常用的功能都具備了。

 
  1. [Setup]  
  2. ; 注: AppId的值為單獨標識該應用程式。  
  3. ; 不要為其他安裝程式使用相同的AppId值。  
  4. ; (產生新的GUID,點擊 工具|在IDE中產生GUID。)  
  5. AppId={{A9861883-31C5-4324-BD9A-DC3271EEB675}  
  6. ;程式名  
  7. AppName=ISsample  
  8. ;版本號碼  
  9. AppVerName=ISsample 1.0.0.0  
  10. ;發行者名  
  11. AppPublisher=Hkiss  
  12. ;相關串連  
  13. AppPublisherURL=http://zwkufo.blog.163.com  
  14. AppSupportURL=http://zwkufo.blog.163.com  
  15. AppUpdatesURL=http://zwkufo.blog.163.com  
  16. ;預設安裝目錄  
  17. DefaultDirName={pf}\ISsample  
  18. ;預設開始菜單名  
  19. DefaultGroupName=ISsample  
  20. ;是否開啟->可選安裝開始功能表項目  
  21. ;AllowNoIcons=yes  
  22. ;安裝協議  
  23. ;LicenseFile=C:\Example\原始檔案\agreement.txt  
  24. ;安裝前查看的文字檔  
  25. ;InfoBeforeFile=C:\Example\原始檔案\Setup_New.txt  
  26. ;安裝後查看文字檔  
  27. ;InfoAfterFile=C:\Example\原始檔案\Setup_Old.txt  
  28. ;輸出檔案夾  
  29. OutputDir=C:\Example\InnoSetup\out  
  30. ;輸出檔案名  
  31. OutputBaseFilename=setup  
  32. ;安裝表徵圖  
  33. SetupIconFile=C:\Example\原始檔案\title.ico  
  34. ;安裝需要輸入密碼  
  35. ;Password=123  
  36. ;Encryption=yes  
  37.   
  38. ;壓縮相關  
  39. Compression=lzma  
  40. SolidCompression=yes  
  41.   
  42. ;可以讓使用者忽略選擇語言相關  
  43. ShowLanguageDialog = yes  
  44. ;備忘版本資訊  
  45. VersionInfoCompany=HTTP://www.Hkiss.COM  
  46. VersionInfoDescription=ISsample 漢化增強版  
  47. VersionInfoVersion=1.0.0.0  
  48. VersionInfoCopyright=Copyright (C) 2007-2008 Hkiss  
  49.   
  50. ;製作選擇語言  
  51. [Languages]  
  52. Name: "chs"; MessagesFile: "compiler:Default.isl" ;LicenSeFile :"C:\Example\原始檔案\chs\agreement.txt"  
  53. Name: "en"; MessagesFile: "compiler:Languages\English.isl";LicenSeFile :"C:\Example\原始檔案\en\agreement.txt"  
  54.   
  55. ;使用者定製任務  
  56. [Tasks]  
  57. Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked  
  58. Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked  
  59. Name: "Tasks_1" ; Description:"使用者自訂任務1"; Flags: unchecked  
  60. Name: "Tasks_2" ; Description:"使用者自訂任務2"; Flags: unchecked  
  61. ;選擇了組件才會出現的定製任務  
  62. Name: "Tasks_3" ; Description:"使用者自訂任務3";Components: c1 ; Flags: unchecked  
  63.   
  64. ;檔案安裝  
  65. [Files]  
  66. ;多語言安裝環境設定    公用參數Languages 來設定  
  67. Source: "C:\Example\原始檔案\enfile.txt"; DestDir: "{app}"; Languages: en ; Flags: ignoreversion  
  68. Source: "C:\Example\原始檔案\chsfile.txt"; DestDir: "{app}"; Languages: chs ; Flags: ignoreversion  
  69. ;使用者自訂任務 Tasks  
  70. Source: "C:\Example\原始檔案\Tasks\tasks_1.txt"; DestDir: "{app}\Tasks"; Flags: ignoreversion ;Tasks : Tasks_1  
  71. Source: "C:\Example\原始檔案\Tasks\tasks_2.txt"; DestDir: "{app}\Tasks"; Flags: ignoreversion ;Tasks :Tasks_2  
  72. Source: "C:\Example\原始檔案\Tasks\tasks_Components.txt"; DestDir: "{app}\Tasks"; Flags: ignoreversion ;Tasks :Tasks_2  
  73. ;使用者定義組件安裝  
  74. Source: "C:\Example\原始檔案\Components\Components_1.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a1;  
  75. Source: "C:\Example\原始檔案\Components\Components_2.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a2;  
  76. Source: "C:\Example\原始檔案\Components\Components_3.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a3;  
  77. Source: "C:\Example \原始檔案\Components\Components_4.txt"; DestDir: "{app} \Components"; Flags: ignoreversion ; Components: a1 a2 a3;  
  78.   
  79. ;使用者註冊自訂Dll檔案      regserver 註冊 noregerror 不顯示錯誤資訊  
  80. Source: "C:\Example\原始檔案\jmail.dll"; DestDir: "{app}"; Flags: ignoreversion regserver  
  81. ;添加讀我檔案  
  82. Source: "C:\Example\原始檔案\ISsample.txt"; DestDir: "{app}"; Flags: ignoreversion  
  83. ;添加一個檔案到快取檔案夾{Tmp} deleteafterinstall 安裝後刪除  
  84. Source: "C:\Example\原始檔案\test.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall  
  85.   
  86. Source: "C:\Example\原始檔案\ISsample.chm"; DestDir: "{app}"; Flags: ignoreversion  
  87. Source: "C:\Example\原始檔案\ISsample.exe"; DestDir: "{app}"; Flags: ignoreversion  
  88. Source: "C:\Example\原始檔案\ISsample.dll"; DestDir: "{app}"; Flags: ignoreversion  
  89. Source: "C:\Example\原始檔案\ISsample.ini"; DestDir: "{app}"; Flags: ignoreversion  
  90. Source: "C:\Example\原始檔案\ISsample.rar"; DestDir: "{app}"; Flags: ignoreversion  
  91. Source: "C:\Example\原始檔案\ISsample_sys.dll"; DestDir: "{win}\System32"; Flags: ignoreversion  
  92. Source: "C:\Example\原始檔案\log\*"; DestDir: "{app}\log"; Flags: ignoreversion recursesubdirs createallsubdirs  
  93. ; 注意: 不要在任何共用系統檔案上使用“Flags: ignoreversion”  
  94. ;安裝類型設定  
  95. [Types]  
  96. Name: Full ;Description:"完整安裝"; Flags: iscustom  
  97. Name: Compact ;Description:"簡潔安裝";  
  98. Name: Custom; Description:"自訂安裝";  
  99. ;組件安裝  
  100. [Components]  
  101. Name: c1; Description: "自訂任務3" ; Types: Full  
  102. Name: a1; Description: "安裝Components_1"; Types: Full Compact Custom ;  
  103. Name: a2; Description: "安裝Components_2"; Types : Full   Compact  
  104. Name: a3; Description: "安裝Components_3"; Types : Full  
  105.   
  106. ;開始菜單,案頭捷徑  
  107. [Icons]  
  108. Name: "{group}\ISsample"; Filename: "{app}\ISsample.exe"  
  109. Name: "{group}\{cm:ProgramOnTheWeb,ISsample}"; Filename: "http://zwkufo.blog.163.com"  
  110. Name: "{group}\{cm:UninstallProgram,ISsample}"; Filename: "{uninstallexe}"  
  111. Name: "{commondesktop}\ISsample"; Filename: "{app}\ISsample.exe"; Tasks: desktopicon  
  112. Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\ISsample"; Filename: "{app}\ISsample.exe"; Tasks: quicklaunchicon  
  113. ;添加一個協助文擋  
  114. Name: {group}\ISsample 1.0.0.0 協助文檔;Filename: {app}\ISsample.chm  
  115.   
  116. ;用來在程式安裝完成後 在安裝程式顯示最終對話方塊之前執行程式 常用與運行主程式 顯示讀我檔案 刪除臨時檔案  
  117. [Run]  
  118. Filename: "{app}\ISsample.exe"; Description: "{cm:LaunchProgram,ISsample}"; Flags: nowait postinstall skipifsilent  
  119. Filename: "{app}\ISsample.txt"; Description: "查看顯示讀我檔案"; Flags: postinstall skipifsilent shellexec  
  120.   
  121. ;更改顯示在程式中顯示的訊息文本  
  122. [Messages]  
  123. BeveledLabel=HKiss科技  
  124. ;卸載對話方塊說明  
  125. ConfirmUninstall=您真的想要從電腦中卸載ISsample嗎?%n%n按 [是] 則完全刪除 %1 以及它的所有組件;%n按 [否]則讓軟體繼續留在您的電腦上.  
  126. ;定義解壓說明  
  127. ;StatusExtractFiles=解壓並複製主程式檔案及相關庫檔案...  
  128.   
  129. ;用於在使用者系統中建立,修改或刪除ini檔案健值  
  130. [INI]  
  131. Filename: "{app}\cfg.ini"; Section: "Startup Options"; Flags: uninsdeletesection  
  132. Filename: "{app}\cfg.ini"; Section: "Startup Options"; Key: "server ip"; String: "127.0.0.1"  
  133. Filename: "{app}\cfg.ini"; Section: "Startup Options"; Key: "server port"; String: "8080"  
  134.   
  135. ;用於在使用者系統中建立,修改或刪除註冊表健值  
  136. [Registry]  
  137. Root: HKLM ;SubKey:"Software\ISsample";ValueType:dword;ValueName:config;ValueData:10 ;Flags:uninsdeletevalue  
  138. ;在執行指令碼  
  139. [code]  
  140. //全域變數  
  141. var MyProgChecked: Boolean;  
  142.   
  143. //判斷程式是否存在  
  144. //初始華程式事件  
  145. function InitializeSetup(): boolean;  
  146. var Isbl: boolean;         //聲明變數  
  147. var Isstr: string;  
  148. begin       //開始  
  149. Isbl := true;             //變數賦值  
  150. Isstr := ‘歡迎‘;  
  151. if RegValueExists(HKEY_LOCAL_MACHINE, ‘SOFTWARE\ISsample‘, ‘config‘) then  
  152. begin  
  153.     MsgBox(‘已安裝過,請先卸載在安裝‘,mbConfirmation, MB_OK);  
  154.     isbl := false;  
  155. end else  
  156. begin  
  157.    //MsgBox(‘無值‘,mbConfirmation, MB_OK);  
  158.      isbl := true;  
  159. end;  
  160.   
  161. //下面是個麻煩的 條件陳述式 end else 注意  
  162. //if MsgBox(Isstr, mbConfirmation, MB_OKCANCEL) = IDOK then  
  163. //begin  
  164. // isbl := true;  
  165. // MsgBox(‘執行了‘, mbConfirmation, MB_OK);  
  166. //end else  
  167. //begin  
  168. // isbl := false;  
  169. //MsgBox(‘執行了‘, mbConfirmation, MB_OK);  
  170. //end;  
  171.   
  172. Result := Isbl;  
  173. end;       //結束  
  174.   
  175. procedure CurStepChanged(CurStep: TSetupStep);  
  176. var Isstr :string;  
  177. begin  
  178. if CurStep=ssInstall then       //實際安裝前調用  
  179. begin  
  180.     //MsgBox(‘CurStepChanged:實際安裝前調用‘, mbConfirmation, MB_OKCANCEL);           //安裝完成後調用  
  181. end;  
  182. if CurStep=ssPostInstall then  
  183. begin  
  184.     Isstr := ExpandConstant(‘{tmp}\tmp.rar‘);  
  185. //    if FileExists(Isstr) then  
  186. //    begin  
  187. //      MsgBox(‘檔案存在‘,mbConfirmation, MB_OK);  
  188. //    end else  
  189. //    begin  
  190. //      MsgBox(‘檔案不存在‘,mbConfirmation, MB_OK);  
  191. //    end;  
  192.    // MsgBox(‘CurStepChanged:實際安裝後調用‘, mbConfirmation, MB_OKCANCEL);  
  193. end;  
  194. end;  
  195.   
  196. //下一步 按鈕按鈕 事件  
  197. function NextButtonClick(CurPageID: Integer): Boolean;  
  198. var ResultCode: Integer;  
  199. var IsSetup : Boolean;  
  200. begin  
  201. IsSetup := true ;  
  202. case CurPageID of  
  203.     wpSelectDir:  
  204.        MsgBox(‘NextButtonClick:‘ #13#13 ‘You selected: ‘‘‘ + WizardDirValue + ‘‘‘.‘, mbInformation, MB_OK);   //WizardDirValue 路徑  
  205.     wpSelectProgramGroup:  
  206.        MsgBox(‘NextButtonClick:‘ #13#13 ‘You selected: ‘‘‘ + WizardGroupValue + ‘‘‘.‘, mbInformation, MB_OK); //開始菜單名  
  207.     wpReady:  
  208.       begin  
  209.        if not RegValueExists(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Test‘, ‘config‘) then   begin  
  210.           if MsgBox(‘程式執行需要Test.ext,是否安裝!‘, mbConfirmation, MB_YESNO) = idYes then begin  
  211.            ExtractTemporaryFile(‘test.exe‘);  
  212.             if not Exec(ExpandConstant(‘{tmp}\test.exe‘), ‘‘, ‘‘, SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then  
  213.               MsgBox(‘Test.exe出錯:‘ #13#13 ‘ ‘ + SysErrorMessage(ResultCode) + ‘.‘, mbError, MB_OK);  
  214.           end else begin  
  215.                 IsSetup := false ;  
  216.           end ;  
  217.           BringToFrontAndRestore();  
  218.         end;  
  219.       end;  
  220. end;  
  221. Result := IsSetup;  
  222. end;  

一個比較完整的Inno Setup 安裝指令碼(轉)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.