Thursday, February 2, 2012

Mazda EPC 2 Portable Launcher

I've searched a lot around the net for a portable version of Mazda EPC (Electronic Parts Catalogue) 2, but didn't found anything, so I decided to do it myself (back in 2010). Installation of Mazda's EPC is really pain in the ass, not to mention you loose all of your History when reinstalling. Here I'll show you 3 things:
1. How to prepare Mazda EPC 2 to be ready for portable launching
2. How to make your portable launcher.
3. Links to my portable launcher and source, in case you don't want to compile yourself (you still need to prepare the EPC though)

Ok, lets go!

Note: No PortableApps.com Format Specifications are met as there were none back in 2010. Still, this launcher works like a charm even in the latest PortableApps.com platform.

Part 1 (preparing Mazda EPC 2 to be ready for portable launching):
1. (Optional, but recommended) Install Windows on a virtual machine.
2. Install your Mazda EPC 2
3. Import all of your CDs in the same folder as your BIN folder.
4. On your PC (or on another PC, if you don't use virtual PC) create a folder to store your portable version of EPC. Inside of it create 2 folders - App and Data.
5. Copy all of your EPC files in App folder.
6. In Data folder create folder called Settings. In Settings folder you should put 2 files - borland.reg and MAZEPC.INI (this one I recommend you to get it from your own installation - it's stored in your Windows folder, e.g. C:\Windows)
End structure should be:
MAZDAEPC
- App
-- A1 (if you have this disk installed)
-- A2 (if you have this disk installed)
-- B1 (if you have this disk installed)
-- B2 (if you have this disk installed)
-- B3 (if you have this disk installed)
-- BACKUP
-- BIN
-- LOCAL
-- SAVE
- Data
-- Settings
7. Now prepare the launcher (part 2) or download it (part 3) and put it a side to your App and Data folders.
8. Run the launcher. You should get an error of a missing file. Go to the PC you installed Mazda EPC, find the file (typically in your System32 folder) and copy it inside your App\BIN folder (so it's next to mazdaepc.exe). Do this for all the files needed and in the end you should get Mazda EPC 2 protable running ;) I don't remember the list of files you need to copy, as I did this two years ago, but that's the way I've done it and it's working perfectly (tested on XP x86, Vista x64, 7 x86 and x64 and even 8 Developers Preview x64).
9. Enjoy!

Part 2 (writing and compiling the launcher)
1. Either install NSIS or download it portable from PortableApps.com
2. (Optional if you want icon) Either install IcoFX (or other icon editing software) or download it portable from PortableApps.com
3. Make a file called Mazda.nsi and paste the following code in it:

SetCompress force
SetCompressor /SOLID /FINAL LZMA
SetDatablockOptimize on
!include 'LogicLib.nsh'
!include "Registry.nsh"
Name "Mazda EPC2"
OutFile "MazdaEPC2Portable.exe"
VIProductVersion 1.0.0.0
VIAddVersionKey ProductName "Mazda EPC2"
VIAddVersionKey Comments "by metal03326"
VIAddVersionKey FileDescription "Launcher for Mazda EPC2"
VIAddVersionKey FileVersion 1.0.0.0
VIAddVersionKey ProductVersion 1.0.0.0
VIAddVersionKey LegalCopyright "Copyrights 2010"
CRCCheck off
SilentInstall silent
XPSTYLE on
Icon "Icon.ico" // Remove this line if you don't want Mazda's icon
Var AppDir
Var SETTINGSDIRECTORY
Section 'Main'
StrCpy $SETTINGSDIRECTORY "$EXEDIR\Data\Settings"
StrCpy $AppDir "$EXEDIR\App"
ReadINIStr $0 $SETTINGSDIRECTORY\MAZEPC.INI "ExecEnv" "InstallPath"
StrCmp $0 "$AppDir" +2 0
WriteINIStr $SETTINGSDIRECTORY\MAZEPC.INI "ExecEnv" "InstallPath" "$AppDir"
ReadINIStr $0 $SETTINGSDIRECTORY\MAZEPC.INI "ExecEnv" "SavePath"
StrCmp $0 "$AppDir\SAVE" +2 0
WriteINIStr $SETTINGSDIRECTORY\MAZEPC.INI "ExecEnv" "SavePath" "$AppDir\SAVE"
ReadINIStr $0 $SETTINGSDIRECTORY\MAZEPC.INI "ExecEnv" "LocalPath"
StrCmp $0 "$AppDir\LOCAL" +2 0
WriteINIStr $SETTINGSDIRECTORY\MAZEPC.INI "ExecEnv" "LocalPath" "$AppDir\LOCAL"
ReadINIStr $0 $SETTINGSDIRECTORY\MAZEPC.INI "ExecEnv" "BkupDir"
StrCmp $0 "$AppDir\BACKUP" +2 0
WriteINIStr $SETTINGSDIRECTORY\MAZEPC.INI "ExecEnv" "BkupDir" "$AppDir\BACKUP"
${For} $R0 1 10
ReadINIStr $0 $SETTINGSDIRECTORY\MAZEPC.INI "ExecEnv" "DataPath$R0"
StrCmp $0 '' +4 0
StrCpy $R1 $0 2 #
StrCmp $0 "$R1,$AppDir\$R1" +2 0
WriteINIStr $SETTINGSDIRECTORY\MAZEPC.INI "ExecEnv" "DataPath$R0" "$R1,$AppDir\$R1"
${Next}
CopyFiles $SETTINGSDIRECTORY\MAZEPC.INI "$WINDIR\MAZEPC.INI"
IfFileExists $SETTINGSDIRECTORY\borland.bak 0 +5
Messagebox MB_YESNO|MB_ICONEXCLAMATION "Previous registry backup of 'HKLM\SOFTWARE\Borland' found. This maybe is caused by improper termination last time. If this is the case and the termination was done on this computer, please click 'Yes'. Do you want to use this backup before continuing?" IDYES +1 IDNO +3
DeleteRegKey HKLM "SOFTWARE\Borland"
nsExec::ExecToStack `"$WINDIR\system32\reg.exe" import "$SETTINGSDIRECTORY\borland.bak"`
Delete $SETTINGSDIRECTORY\borland.bak
ClearErrors
EnumRegKey $0 HKLM "SOFTWARE\Borland" 0
IfErrors 0 +2
Goto +5
nsExec::ExecToStack `"$WINDIR\system32\reg.exe" export "HKLM\SOFTWARE\Borland" "$SETTINGSDIRECTORY\borland.bak"`
Pop $R0
StrCmp $R0 '0' 0 +10
DeleteRegKey HKLM "SOFTWARE\Borland"
nsExec::ExecToStack `"$WINDIR\system32\reg.exe" import "$SETTINGSDIRECTORY\borland.reg"`
SetOutPath "$AppDir"
ExecWait "$OUTDIR\BIN\mazdaepc.exe"
Delete $WINDIR\MAZEPC.INI
IfFileExists $SETTINGSDIRECTORY\borland.bak 0 +4
DeleteRegKey HKLM "SOFTWARE\Borland"
nsExec::ExecToStack `"$WINDIR\system32\reg.exe" import "$SETTINGSDIRECTORY\borland.bak"`
Delete $SETTINGSDIRECTORY\borland.bak
SectionEnd
4. (Optional if you want icon) Extract mazdaepc.exe icon with IcoFX (or other icon editing software) and place it next to Mazda.nsi
5. Compile Mazda.nsi with NSIS and you should get MazdaEPC2Portable.exe file next to Mazda.nsi
6. Place it next to App and Data folders from your prepared (part 1) Mazda EPC 2 portable and run it!
7. Enjoy.

Part 3 (download time!)
Here are links from previous 2 parts as well as links for the source code and the compiled launcher. Enjoy!
borland.reg
My MAZEPC.INI (I really recommend using yours)
Source code (Mazda.nsi)
Compiled binary (MazdaEPC2Portable.exe)

No comments :

Post a Comment