Created
March 11, 2012 11:05
-
-
Save riipandi/2016013 to your computer and use it in GitHub Desktop.
BAIK Interpreter Setup Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ----------------------------------- | |
; BAIK 7.0 INNO Installer SCript | |
; Aris S Ripandi ([email protected]) | |
; ----------------------------------- | |
[Setup] | |
AppId={{87CBA5F1-7CDC-44E9-BFEB-3D1E7841A2C2} | |
AppName=BAIK Interpreter | |
AppVersion=7.0 | |
AppPublisher=Haris Hasanudin,MSc. | |
AppPublisherURL=http://sourceforge.net/projects/baik | |
AppUpdatesURL=http://sourceforge.net/projects/baik | |
AppCopyright=Copyright (C) Haris Hasanudin,MSc. | |
DefaultDirName=C:\baik | |
DisableDirPage=yes | |
DefaultGroupName=BAIK-7 | |
AllowNoIcons=yes | |
LicenseFile=LISENSI_SETUP.txt | |
InfoBeforeFile=..\baik_win_bin_07\press_release_ver7.txt | |
;InfoAfterFile=SESUDAH_INSTAL.txt | |
OutputDir=../ | |
OutputBaseFilename=baik_7_setup | |
SetupIconFile=style\icon_setup.ico | |
CreateAppDir=yes | |
WindowVisible=yes | |
BackColor=clBlue | |
BackColor2=clBlack | |
WizardImageFile=style\Office2007Gray.bmp | |
WizardSmallImageFile=style\installer-top.bmp | |
WizardImageStretch=yes | |
ShowLanguageDialog=yes | |
Compression=lzma/max | |
SolidCompression=yes | |
ShowTasksTreeLines=yes | |
ChangesEnvironment=true | |
ChangesAssociations=yes | |
[Languages] | |
Name: "en"; MessagesFile: "compiler:Default.isl" | |
Name: "id"; MessagesFile: "Indonesian.isl" | |
[Messages] | |
BeveledLabel= http://sourceforge.net/projects/baik | |
[CustomMessages] | |
id.IkonDesktop=Buat Pintasan di Desktop Untuk BAIK Shell | |
en.IkonDesktop=Create Desktop Shortcut for BAIK Shell | |
id.Tambahan=Lain - lain | |
en.Tambahan=Extra Task | |
id.IkonQL=Buat Pintasan di Quick Launch Untuk BAIK Shell | |
en.IkonQL=Create Quick Launch Icon for BAIK Shell | |
id.Asosiasi=Asosiasikan file .ina dengan BAIK | |
en.Asosiasi=Associate .ina files with BAIK | |
id.Konteks=Buat Konteks Menu Run With BAIK | |
en.Konteks=Create Context Menu Run With BAIK | |
id.InstallGTK=Install GTK Runtime | |
en.InstallGTK=Install GTK Runtime | |
id.JalankanBAIK=Jalankan BAIK Shell | |
en.JalankanBAIK=Run BAIK Shell | |
id.RegPath=Register Envirenment Variable (Wajib) | |
en.RegPath=Register Envirenment Variable (Required) | |
[Tasks] | |
Name: desktopicon; Description: {cm:IkonDesktop}; GroupDescription: {cm:Tambahan}; | |
Name: launchicon; Description: {cm:IkonQL}; GroupDescription: {cm:Tambahan}; Flags: unchecked | |
Name: associate; Description: {cm:Asosiasi}; GroupDescription: {cm:Tambahan}; | |
Name: konteksmenu; Description: {cm:Konteks}; GroupDescription: {cm:Tambahan}; | |
Name: installgtk; Description: {cm:InstallGTK}; GroupDescription: {cm:Tambahan}; Flags: dontinheritcheck | |
Name: modifypath; Description: {cm:RegPath}; GroupDescription: {cm:Tambahan}; | |
[Files] | |
; File utama baik | |
Source: ".\baik_shell.bat"; DestDir: "{app}"; Flags: ignoreversion | |
Source: "..\baik_win_bin_07\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs | |
; Library GTK 2.0 | |
Source: "..\_gtk2.0_bin\*"; DestDir: "{pf}\GTK2.0"; CopyMode: onlyifdoesntexist; Flags: ignoreversion recursesubdirs createallsubdirs; Tasks: installgtk | |
; Dll untuk skin installer | |
Source: ISSkin.dll; DestDir: {app}; Flags: dontcopy | |
; Tambahkan style visual | |
Source: style\Office2007.cjstyles; DestDir: {tmp}; Flags: dontcopy | |
[Icons] | |
Name: "{group}\BAIK Shell Prompt"; Filename: "{app}\baik_shell.bat"; HotKey: "ctrl+alt+b"; WorkingDir: {app}; | |
Name: "{commondesktop}\BAIK Shell Prompt"; Filename: "{app}\baik_shell.bat"; WorkingDir: {app}; Tasks: desktopicon | |
Name: "{group}\BAIK Website"; Filename: "{app}\baik-homepage.url" | |
Name: "{group}\Press Release"; Filename: "{app}\press_release_ver7.txt"; WorkingDir: {app}; | |
Name: "{group}\Panduan BAIK"; Filename: "{app}\petunjuk_pemakaian_ver7.txt"; WorkingDir: {app}; | |
Name: "{group}\{cm:UninstallProgram,BAIK}"; Filename: "{uninstallexe}"; WorkingDir: {app}; | |
Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\BAIK Shell Prompt; Filename: "{app}\baik_shell.bat"; WorkingDir: {app}; Tasks: launchicon | |
[Registry] | |
; Environment Untuk GTK | |
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "LANG"; ValueData: "id"; Tasks: installgtk | |
Root: HKCU; Subkey: "Environment"; ValueType: string; ValueName: "LANG"; ValueData: "id"; Flags: uninsdeletekey; Tasks: installgtk | |
Root: HKCR; Subkey: ".ina"; ValueType: string; ValueName: ""; ValueData: "BAIK Source File"; Flags: uninsdeletevalue; Tasks: associate | |
Root: HKCR; Subkey: "BAIK"; ValueType: string; ValueName: ""; ValueData: "BAIK Interpreter"; Flags: uninsdeletekey; Tasks: associate | |
Root: HKCR; Subkey: "BAIK\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\icon_BAIK.ico"; Tasks: associate | |
Root: HKCR; Subkey: "BAIK\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\baik.exe"" ""%1"""; Tasks: associate | |
;Konteks menu | |
Root: HKCR; Subkey: ".ina\shell"; ValueType: string; ValueName: ""; ValueData: ""; Flags: uninsdeletevalue; Tasks: konteksmenu | |
Root: HKCR; Subkey: ".ina\shell\Run with BAIK"; ValueType: string; ValueName: ""; ValueData: ""; Flags: uninsdeletevalue; Tasks: konteksmenu | |
Root: HKCR; Subkey: ".ina\shell\Run with BAIK\command"; ValueType: string; ValueName: "";ValueData: """{app}\baik.exe"" ""%1"""; Flags: uninsdeletevalue; Tasks: konteksmenu | |
[Run] | |
Filename: "{app}\baik_shell.bat"; Description: {cm:JalankanBAIK}; Flags: nowait postinstall skipifsilent unchecked | |
; Kode dibawah ini untuk memuat skin | |
[Code] | |
const | |
ModPathName = 'modifypath'; | |
ModPathType = 'system'; | |
//----------------------- Kode untuk Skin Installer -----------------------// | |
procedure LoadSkin(lpszPath: String; lpszIniFileName: String); | |
external 'LoadSkin@files:isskin.dll stdcall'; | |
procedure UnloadSkin(); | |
external 'UnloadSkin@files:isskin.dll stdcall'; | |
function ShowWindow(hWnd: Integer; uType: Integer): Integer; | |
external '[email protected] stdcall'; | |
function InitializeSetup(): Boolean; | |
begin | |
ExtractTemporaryFile('Office2007.cjstyles'); | |
LoadSkin(ExpandConstant('{tmp}\Office2007.cjstyles'), 'NormalBlack.ini'); | |
Result := True; | |
end; | |
procedure DeinitializeSetup(); | |
begin | |
ShowWindow(StrToInt(ExpandConstant('{wizardhwnd}')), 0); | |
UnloadSkin(); | |
end; | |
//----------------------- Kode untuk Register Path -----------------------// | |
function ModPathDir(): TArrayOfString; | |
begin | |
setArrayLength(Result, 3) | |
Result[0] := ExpandConstant('{app}'); | |
Result[2] := ExpandConstant('{app}\pustaka'); | |
Result[1] := ExpandConstant('{pf}\GTK2.0\bin'); | |
end; | |
;#include "modpath.iss" | |
;;;; modpath | |
// ---------------------------------------------------------------------------- | |
// | |
// Inno Setup Ver: 5.3.10 | |
// Script Version: 1.4.0 | |
// Author: Jared Breland <[email protected]> | |
// Homepage: http://www.legroom.net/software | |
// | |
// Script Function: | |
// Allow modification of environmental path directly from Inno Setup installers | |
// | |
// Instructions: | |
// Copy modpath.iss to the same directory as your setup script | |
// | |
// Add this statement to your [Setup] section | |
// ChangesEnvironment=true | |
// | |
// Add this statement to your [Tasks] section | |
// You can change the Description or Flags | |
// You can change the Name, but it must match the ModPathName setting below | |
// Name: modifypath; Description: &Add application directory to your environmental path; Flags: unchecked | |
// | |
// Add the following to the end of your [Code] section | |
// ModPathName defines the name of the task defined above | |
// ModPathType defines whether the 'user' or 'system' path will be modified | |
// this will default to user if anything other than user or system is set | |
// setArrayLength must specify the total number of dirs to be added | |
// Result[0] contains first directory, Result[1] contains second, etc. | |
// const | |
// ModPathName = 'modifypath'; | |
// ModPathType = 'user'; | |
// | |
// function ModPathDir(): TArrayOfString; | |
// begin | |
// setArrayLength(Result, 1) | |
// Result[0] := ExpandConstant('{app}'); | |
// end; | |
// #include "modpath.iss" | |
// ---------------------------------------------------------------------------- | |
procedure ModPath(); | |
var | |
oldpath: String; | |
newpath: String; | |
updatepath: Boolean; | |
pathArr: TArrayOfString; | |
aExecFile: String; | |
aExecArr: TArrayOfString; | |
i, d: Integer; | |
pathdir: TArrayOfString; | |
regroot: Integer; | |
regpath: String; | |
begin | |
// Get constants from main script and adjust behavior accordingly | |
// ModPathType MUST be 'system' or 'user'; force 'user' if invalid | |
if ModPathType = 'system' then begin | |
regroot := HKEY_LOCAL_MACHINE; | |
regpath := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'; | |
end else begin | |
regroot := HKEY_CURRENT_USER; | |
regpath := 'Environment'; | |
end; | |
// Get array of new directories and act on each individually | |
pathdir := ModPathDir(); | |
for d := 0 to GetArrayLength(pathdir)-1 do begin | |
updatepath := true; | |
// Modify WinNT path | |
if UsingWinNT() = true then begin | |
// Get current path, split into an array | |
RegQueryStringValue(regroot, regpath, 'Path', oldpath); | |
oldpath := oldpath + ';'; | |
i := 0; | |
while (Pos(';', oldpath) > 0) do begin | |
SetArrayLength(pathArr, i+1); | |
pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath)-1); | |
oldpath := Copy(oldpath, Pos(';', oldpath)+1, Length(oldpath)); | |
i := i + 1; | |
// Check if current directory matches app dir | |
if pathdir[d] = pathArr[i-1] then begin | |
// if uninstalling, remove dir from path | |
if IsUninstaller() = true then begin | |
continue; | |
// if installing, flag that dir already exists in path | |
end else begin | |
updatepath := false; | |
end; | |
end; | |
// Add current directory to new path | |
if i = 1 then begin | |
newpath := pathArr[i-1]; | |
end else begin | |
newpath := newpath + ';' + pathArr[i-1]; | |
end; | |
end; | |
// Append app dir to path if not already included | |
if (IsUninstaller() = false) AND (updatepath = true) then | |
newpath := newpath + ';' + pathdir[d]; | |
// Write new path | |
RegWriteStringValue(regroot, regpath, 'Path', newpath); | |
// Modify Win9x path | |
end else begin | |
// Convert to shortened dirname | |
pathdir[d] := GetShortName(pathdir[d]); | |
// If autoexec.bat exists, check if app dir already exists in path | |
aExecFile := 'C:\AUTOEXEC.BAT'; | |
if FileExists(aExecFile) then begin | |
LoadStringsFromFile(aExecFile, aExecArr); | |
for i := 0 to GetArrayLength(aExecArr)-1 do begin | |
if IsUninstaller() = false then begin | |
// If app dir already exists while installing, skip add | |
if (Pos(pathdir[d], aExecArr[i]) > 0) then | |
updatepath := false; | |
break; | |
end else begin | |
// If app dir exists and = what we originally set, then delete at uninstall | |
if aExecArr[i] = 'SET PATH=%PATH%;' + pathdir[d] then | |
aExecArr[i] := ''; | |
end; | |
end; | |
end; | |
// If app dir not found, or autoexec.bat didn't exist, then (create and) append to current path | |
if (IsUninstaller() = false) AND (updatepath = true) then begin | |
SaveStringToFile(aExecFile, #13#10 + 'SET PATH=%PATH%;' + pathdir[d], True); | |
// If uninstalling, write the full autoexec out | |
end else begin | |
SaveStringsToFile(aExecFile, aExecArr, False); | |
end; | |
end; | |
end; | |
// Write file to flag modifypath was selected | |
// Workaround since IsTaskSelected() cannot be called at uninstall and AppName and AppId cannot be "read" in Code section | |
if IsUninstaller() = false then | |
SaveStringToFile(ExpandConstant('{app}') + '\uninsTasks.txt', WizardSelectedTasks(False), False); | |
end; | |
procedure CurStepChanged(CurStep: TSetupStep); | |
var | |
taskname: String; | |
begin | |
taskname := ModPathName; | |
if CurStep = ssPostInstall then | |
if IsTaskSelected(taskname) then | |
ModPath(); | |
end; | |
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); | |
var | |
appdir: String; | |
aSelectedTasks: TArrayOfString; | |
i: Integer; | |
taskname: String; | |
begin | |
taskname := ModPathName; | |
appdir := ExpandConstant('{app}') | |
if CurUninstallStep = usUninstall then begin | |
if LoadStringsFromFile(appdir + '\uninsTasks.txt', aSelectedTasks) then | |
for i := 0 to GetArrayLength(aSelectedTasks)-1 do | |
if aSelectedTasks[i] = taskname then | |
ModPath(); | |
DeleteFile(appdir + '\uninsTasks.txt'); | |
end; | |
end; | |
function NeedRestart(): Boolean; | |
var | |
taskname: String; | |
begin | |
taskname := ModPathName; | |
if IsTaskSelected(taskname) and not UsingWinNT() then begin | |
Result := True; | |
end else begin | |
Result := False; | |
end; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment