Boot multiple Minecraft versions (modded and non) simply from one little batch!



Minecraft.bat:

Code:

@ECHO off
:initiate
set /A Counter=0
set Version=?
set /A Args=0

setlocal ENABLEDELAYEDEXPANSION
:handleargs

:list
cls
set /A Counter=0
echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
echo XX                                      XX
echo XX         Minecraft Multiboot          XX
echo XX                 by Komak57           XX
echo XX                                      XX
echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
echo   0: Default
for /f "usebackq tokens=*" %%i in (`dir /b/o:e`) do (
   if exist "%%~nxi\.minecraft" (
      set /A Counter+=1
      echo   !Counter!: %%~nxi
   )
)
echo -------------------------
echo   n: New empty version
echo   b: Backup Default
echo   d: Delete version
echo   e: Exit Program
echo -------------------------

:input
set INPUT=
set /P INPUT=Version: %=%
if "%INPUT%"=="" goto list
if %INPUT%==0 (goto run)
if %INPUT%==b (goto backup)
if %INPUT%==e (goto end)
if %INPUT%==n (goto new)
if %INPUT%==d (goto delete)
set /A Counter=0
for /f "usebackq tokens=*" %%i in (`dir /b/o:e`) do (
   if exist "%%~nxi\.minecraft" (
      set /A Counter+=1
      if !Counter!==%INPUT% (
         set Version=%%~nxi
         goto run
      )
   )
)
echo Invalid Choice
goto :list

:run
if !Version!==? (
   echo Running default version.
   PAUSE
   minecraft.exe
) else (
   echo Running !Version!
   PAUSE
   set APPDATA=!Version!
   minecraft.exe
)
goto end

:new
echo New Version Folder...(leave blank to cancel)
set INPUT=
set /P INPUT=Folder Name: %=%
if "%INPUT%"=="" (goto list)
md "%INPUT%"
md "%INPUT%\.minecraft"
goto list

:backup
echo Back up Version(leave blank to cancel)
echo *NOTE* This will overwrite existing folders
set INPUT=
set /P INPUT=Save As: %=%
if "%INPUT%"=="" (goto list)
md "%INPUT%"
md "%INPUT%\.minecraft"
echo Copying! This may take a bit...
XCOPY /E/Y/Q "%APPDATA%\.minecraft" "%INPUT%\.minecraft"
PAUSE
goto list

:delete
echo Delete...(leave blank to cancel)
set INPUT=
set /P INPUT=Folder Number: %=%
if "%INPUT%"=="" (goto list)
set /A Counter=0
for /f "usebackq tokens=*" %%i in (`dir /b/o:e`) do (
   if exist "%%~nxi\.minecraft" (
      set /A Counter+=1
      if !Counter!==%INPUT% (
         echo Deleting...
         rmdir /s /q "%%~nxi"
      )
   )
)
goto list

:end
endlocal
echo Goodbye :3 -Komak57
exit


Rundown:
Automatically locates and lists any number of alternative minecraft versions.
1) Create Minecraft.bat and place it in a folder of your choice.
2) Place Minecraft.exe in this same folder
3) Create a subfolder with a unique name
4) Add the .minecraft folder with your desired version into said subfolder
5) Repeat process per-version (swap out mods on the same versions even)
6) Run Minecraft.bat and select your desired version

Folder Layout from example:

Code:
.\Eighth block
.\Eighth block\.minecraft
.\v1.1
.\v1.1\.minecraft
.\Minecraft.bat
.\Minecraft.exe


Changelog:
1) Unlimited the quantity of versions to select from
2) Added the ability to add an empty version folder
3) Added the ability to delete a version folder
4) Added the option to backup your %APPDATA% version

Todo:
1) Add argument handler
1a) Allow shortcut executions of specific versions
Sounds like this could be really useful. Great work!

Moderator Note: I moved this to the respective forum.
Hmm, that actually seems like a moderately useful idea. Can you also make it swap out Minecraft versions? If so, this would be something I might even use myself.
KermMartian wrote:
Hmm, that actually seems like a moderately useful idea. Can you also make it swap out Minecraft versions? If so, this would be something I might even use myself.

yup...
AFAICT, just put the .minecraft folder from each different version into a subfolder, and it should appear when you run the batch file.
Backup your .minecraft folder either manually (for you overachievers), or through the use of this program (for those of you who want to avoid errors).

Run a software like Minecraft Downgrader.exe, or anything else that installs your preferred version of minecraft and install a version you want.

Back up the version again with this little program, and name it whatever you want.

After all the versions you want are downloaded, feel free run this program and select 0: Default, running the original .minecraft location, and force-update it back to standard, or manually restore a backup copy.

Add any mods to any of the version folders (should be folders in the root folder of Minecraft.bat). Rename the folders as you please, it will have no effect on the operation of the program. Manually delete them if you wish, copy them, doesn't matter.

Make a shortcut to Minecraft.bat, name it Minecraft. Right-click, Properties, Change Icon, find your minecraft.exe file. Now you have a desktop Icon that looks like Minecraft, and just runs this little program ^.^

-note- Although the program has a section for input handling, it doesn't handle any arguments. I was thinking the arguments would be a nice way to auto-run one specific version, but if you added any versions, or renamed anything, it could alter the effect of the shortcut.

There is no handler for invalid character input, but there is support for spaces. Just don't try to get smart with it and name a folder "/M!N3CR@F7" or anything >.> Lemme know if you find any other bugs in it?

You could even put this file on a memory unit and take it to your friends house to play off your card, as that WAS the intended function of the original version. Just remember to put any of your versions on the memory unit as well?[/i]
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement