; Script generated by the Inno Script Studio Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Mahjong" #define MyAppVersion "1.00" #define MyAppPublisher "Robin Martin" #define MyAppURL "http://www.mencor.co.za" #define MyAppExeName "Mahjong.htm" #define MyXMJExeName "xPlay_XMahjong.bat" [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={{CC478BD5-1ACF-440E-8A1F-79BE887A52C6} AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={sd}\Mahjong DefaultGroupName=Mahjong AllowNoIcons=yes OutputBaseFilename=Mahjong_Setup Compression=lzma SolidCompression=yes UninstallDisplayName=Mahjong Uninstall [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] Source: "C:\mjzip\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "C:\mjzip\xmj\xPlay_XMahjong.bat"; DestDir: "{app}\xmj"; DestName: "xPlay_XMahjong.bat" ; NOTE: Don't use "Flags: ignoreversion" on any shared system files ;== Provide our modified INI file so XMJ doesn't create it using default settings ;== It goes in C:\users\username + environment variable HOMEPATH has this already Source: "C:\mjzip\xmj\xmj.ini"; DestDir: "{%HOMEPATH}"; Flags: ignoreversion [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{group}\Mahjong XMJ"; Filename: "{app}\xmj\{#MyXMJExeName}" Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon Name: "{group}\{cm:UninstallProgram, {#MyAppName}}"; Filename: "{uninstallexe}" [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: shellexec postinstall skipifsilent ;== This [Code] section gets examined/run anyway. ;== So, we will only hook onto postInstall - to make a final change [Code] //== Custom function to replace a string in a file function FileReplaceString(const FileName, SearchString, ReplaceString: string):boolean; var MyFile : TStrings; MyText : string; begin MyFile := TStringList.Create; try result := true; try //MsgBox('File is ' + FileName, mbInformation, MB_OK); MyFile.LoadFromFile(FileName); MyText := MyFile.Text; if StringChangeEx(MyText, SearchString, ReplaceString, True) > 0 then //Only save if text has been changed. begin; MyFile.Text := MyText; MyFile.SaveToFile(FileName); end; except result := false; end; finally MyFile.Free; end; end; //== We only want to react postInstall procedure CurStepChanged(CurStep: TSetupStep); var bUpdateOK : boolean; sAppFolder : string; sEscAppFolder : string; begin // Log('CurStepChanged(' + IntToStr(Ord(CurStep)) + ') called'); if CurStep = ssPostInstall then begin sAppFolder := ExpandConstant('{app}'); sEscAppFolder := sAppFolder; StringChangeEx(sEscAppFolder, '\', '\\', True); // MsgBox('XMJ launch path adjust failed.'+ #13#13 +' Adjust '+sAppfolder+'\xmj\IErunBat.js manually.' // + #13#13 +'Change "C:\\mjzip\xmj" to "'+sEscAppFolder+'\\xmj"', mbInformation, MB_OK) ; //MsgBox('Post install, adjusting XMJ path in '+sAppFolder+'\xmj\IErunBat.js', mbInformation, MB_OK); bUpdateOK := FileReplaceString(sAppFolder+'\xmj\IErunBat.js', 'C:\\mjzip\\xmj', sEscAppFolder+'\\xmj'); if bUpdateOK = False then MsgBox('XMJ launch path adjust failed.'+ #13#13 +' Adjust '+sAppfolder+'\xmj\IErunBat.js manually.' + #13#13 +'Change "C:\\mjzip\\xmj" to "'+sEscAppFolder+'\\xmj"', mbInformation, MB_OK); //else // MsgBox('Post install update done Ok', mbInformation, MB_OK); end; end;