Batch Start File

In this post at MTS many years back, I gave the batch file I use to start The Sims 2, which combines clearing the cache and backing up key 'hoods with starting the game.


My current batch file for Windows 10 is (without the line numbers),

01: @echo off
02: 
03: set sims2_game=The Sims 2 Ultimate Collection
04: set sims2_home=D:\Program Files (x86)\Origin Games\The Sims 2 Ultimate Collection\Fun with Pets\SP9
05: set sims2_exe=Sims2EP9.exe
06: set sims2_options=
07: 
08: rem Hoods to backup, comma seperated list with no spaces
09: set hoods=E001,F001
10: 
11: set winrar_home="D:\Program Files\WinRAR"
12: set winrar_exe=Rar.exe
13: 
14: for /f "tokens=1,2*" %%A in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal" 2^>nul') do set MY_DOCS_ROOT=%%C
15: 
16: cd %MY_DOCS_ROOT%
17: cd "EA Games\The Sims 2"
18: 
19: echo Cleaning cache
20: for %%f in (accessory.cache cigen.package groups.cache) do if exist %%f del %%f
21: 
22: for /f %%x in ('"time /t"') do set t=%%x
23: set now=%t:~0,2%%t:~3,2%
24: set today=%DATE:~6,4%%DATE:~0,2%%DATE:~3,2%
25: 
26: echo Backing up hoods
27: cd "Neighborhoods"
28: for %%H in (%hoods%) do (echo %%H && %winrar_home%\%winrar_exe% a -idq -r %%H_%today%_%now%.rar %%H\*.*)
29: 
30: echo Starting %sims2_game%
31: "%sims2_home%\TSBin\%sims2_exe%" %sims2_options%

Line 1 stops the batch file from barfing up anything but that which I tell it to.

Lines 3 thru 6 set where my game is installed.

Line 9 is the list of 'hoods to back up (see the comment on line 8 for the format).

Lines 11 and 12 are where my copy of WinRar is installed and what the executable is called.

Line 14 is some magic to work out where my Documents directory is located.

Lines 16 and 17 change into my Sims 2 directory. If playing with Ultimate Collection, see my Simblr post to avoid issues with weird characters in path names.

Line 20 clears the cache by deleting the accessory.cache, cigen.package and groups.cache files.

Lines 22 thru 24 get the current time (as hh:mm) and date (as yyyymmdd).

Lines 27 and 28 backup the 'hoods given in line 9.

Line 31 finally starts the game.