BAT FILE PRIMER Chas Bornemann Sim Cyberworld Hey, it's time to get back to the lesson book now. If ya want a review I'm just to lazy to write one here, so go back and review what I wrote in lessons 1 through 4. I did decide to throw some examples in a final lesson 6. So by the time we are done here with you will be able to write a installer for your track or for any other patch you created. -------------------------------------------- LESSON 5: OH MY WORD - IT'S AN INSTALLER !!! Now for da fun part ! Let's tear an actual installer apart and see what makes it tick !!! But first I want to thank a few people that helped me learn all about these goofy BAT files over the past 2 years. Marcello "Da Man" Bassino, Jaroslaw Polewka and Rudi Kusters. I mentioned earlier I'm dumb as brikcs and widdout da hep of dese fine persons, I'd no nuttin today ! ********************* HATTIESBURG INSTALLER ********************* This BATCH file will be explained in detail using REM statements. REM Can you remember the use of the @echo off statement? If you can't REM do not pass go. Do not collect $100. Return to lesson 1 and start REM over. @ echo off REM This statement checks for the existence of the Chrltte.dat file in REM the chrltte directory. A couple of things VERY IMPORTANT to this REM statement !!! This installer is meant to be run from the tracks REM directory. The . is needed to go to the chrltte directory from REM the tracks directory. REM The typical installation of you N2 game is like this: REM >SIERRA REM > Nascar 2 REM > TRACKS (where the installer is running from REM > CHRLTTE REM If Charlotte is found the program jumps to the :OK statement if exist .\chrltte\chrltte.dat goto OK REM If the chrltte.dat file is NOT FOUND the program goes to :ERROR goto ERROR REM Oops, I guess the chrltte.dat file wasn't found eh? Notice at the REM end of this block the program jumps to the :END statement. Nothing REM in between the GOTO END and :END will be processed. All of those REM lines are skipped !!! :ERROR echo. You must install this patch in your TRACKS directory echo. Please be certain you have CHARLOTTE installed echo. ===================================================== goto END REM Hey, congrats, you had the chrltte.dat file. Now we can install the REM track !!! :OK rem ***** CREATE DIRECTORY ***** REM Makes the Hatties directory (MD is a keyword in DOS that stands for REM "make directory" md hatties REM Copy the Chrltte.dat file to the Hatties directory. Again the installer REM is running from the TRACKS directory !!! The syntax must be exact for REM this process to work !!!! copy .\chrltte\chrltte.dat hatties rem ***** CREATE DAT FILE ***** REM CD is a DOS keyword that stands for Change Directory. We are now REM Changing the directory to the Hatties Directory !!! REM Because we did this the undat and dat commands must be moved before we REM do this !!! Otherwise we should eliminate this line altogether ! REM I have this line in my installers because I am calling the install.bat REM file from another program and this is how it works. If you are writing REM a bat file you may need to modify this. cd hatties REM Unpack the Charlotte DAT file. Then delete the undat file since it is REM no longer needed. undat chrltte.dat /n del undat.exe REM hatties.exe is created using zip2exe. The -o switch means overwrite REM without prompting. This is a ZIP file made into a self-extracting exe REM file. I always include a file called dat.txt in the exe which will build REM the dat file. More on this after I get through the file and describe the REM tools used. hatties.exe -o REM Create the Hattiesburg DAT file and DELETES automatically all extra files REM from the dat.txt file. Also delete the dat.exe and hatties.exe files REM as they are no longer needed. dat hatties.dat /d dat.txt del dat.exe del hatties.exe REM ******* DELETE ROUTINES ************* REM The only reason these lines are needed is because we unpacked the REM original Chrltte.dat file in the directory. We have a bit of cleanup REM to do now. So let's toss out the files we don't need. NEVER use a REM command *.pcx or *.txt !!! Remember the track.txt, records,txt, REM tracklogo.pcx etc... You don't want to delete those !!! del *.3do del *.mip del *.mi4 del *.srb del *.cam del *.trk del *.scr del cloudy.pcx del sunny.pcx del lores.pcx del map.pcx del dat.txt del chrltte.dat del *.3dr del setup REM Change the directory back to TRACKS directory, clear the screen and REM display a ton of credits and disclaimers to keep the lawyers happy ! cd.. cls echo. ************************************************************************ echo. ************************************************************************ echo. ************************************************************************ echo. echo. THIS PATCH MODIFIES THE CHARLOTTE TRACK AND IS echo. INTENDED FOR YOUR PERSONAL USE ONLY !!! echo. echo. DO NOT DISTRIBUTE WITHOUT THE PRIOR WRITTEN CONSENT echo. OF BB&B TRACK EDITING PROJECT. echo. echo. All questions regarding installation and use of this track echo. should be directed to BB&B at echo. http://www.simracing.com/simcyberworld/ echo. echo. TRACK CREATED BY BB&B TRACK EDITING PROJECT. echo. Chas Bornemann echo. Andre De'Boer echo. Marcelo Bassino echo. Brian Fox echo. Matt Harper echo. echo. Thank you and have fun. echo. :END delete install.bat REM deletes the install.bat file ************************* So you are probably thinking, what did I need those other 4 lessons for? You just showed me how to do it in 5 minutes. Well without those other 4 lessons you didn't get the basics and my email box filled up when your program crashed :) DA TOOLS: DAT.EXE UNDAT.EXE - By Marcello Bassino (BB&B) on our tools page Sorry Corey, the Dat/Undat tools are much more powerful and my preferred tools for more than a year now. You can use these tools with Notepad. No hex editing required ! If you need help using them email me. PKZIP.EXE ZIP2EXE.EXE - By da same people that make WInzip. Not sure if it's still on their website though. It's on the net yet and doesn't have the copyright distribution problems of Winzip. NOTEPAD - Windows Notepad that is ! I use it to create all bat files ! Hope you enjoyed this as much as I did. Feel free to ask questions. Chas Bornemann Sim Cyberworld http://www.simracing.com/simcyberworld/ sc@dataplusnet.com ------------------------ LESSON 6 OR - DA EXTRAS: FILE #1 is a INSTALLER I wrote for Eric Mitchell's Spotter Voice Utility. @ echo off if exist .\sound\sound.dat goto OK goto ERROR :ERROR echo. Cannot find the sound.dat file. Please check the echo. path to your Nascar 2 game and try installation echo. again. Afterall, you can't run the dang game echo. without the SOUND.DAT file !!!!!! echo. ==================================================== goto END :OK rem ***** CREATE DAT FILE ***** cd sound copy sound.dat sound.old undat sound.dat /n sound.exe -o dat sound.dat /d dat.txt REM ******* DELETE ROUTINES ************* del undat.exe del dat.exe del sound.exe del dat.txt cd.. cls echo. ************************************************************************ echo. ************************************************************************ echo. ************************************************************************ echo. echo. THIS PATCH INSTALLS A NEW SPOTTER VOICE FOR NASCAR 2 AND echo. IS INTENDED FOR YOUR PERSONAL USE ONLY !!! echo. echo. DO NOT DISTRIBUTE WITHOUT THE PRIOR WRITTEN CONSENT echo. ERIC J MITCHELL AND ETERNITY ENTERPRISES echo. echo. All questions regarding installation and use of this patch echo. should be directed to Eric Mitchell at echo. http://www.fortunecity.com/silverstone/chicane/20/index.htm echo. echo. SOUNDS AND SAMPLINGS BY Eric Mitchell echo. PATCH written by Chas Bornemann echo. echo. Thank you and have fun. echo. :END ------ EXAMPLE 2 - a Batch file I wrote to install Jason Michaud's Cockpits. Simply unpacks the layout.dat file, installs the new files and repacks them. @ echo off cd layout copy layout.dat layout.bak undat layout.dat /a dat.txt cpits.exe -o dat layout.dat /d dat.txt del dat.txt del dat.exe del undat.exe del cpits.exe cd.. :END =============