Summarized from the Microsoft Technet link provided by mjv:
Windows will step through the directories in PATH from left to right (normal list order).
In each of these, it attempts to locate a file with each PATHEXT also left to right, before continuing to the next PATH entry.
The first file it finds wins.
So, in your case, you need to change PATHEXT so that .BAT comes before .EXE (or it will always find .exe first and not the .bat you most likely want to override it, if in the same directory) and also put the path of your 'override' gvim.bat earlier (earliest?) in the PATH listing than anywhere it could find gvim.* (because it tries every PATHEXT in each before going on down PATH)