CCCPaste

RUN.BAT

@ECHO OFF
SETLOCAL EnableDelayedExpansion
::WARNING never run this file unless you are certain of the results. Some of the options in it will create and/or delete massive amounts of files. If not worse things. This is for my use. I will make it public for others to learn from. (if there is anything to learn from this thing)
::
::This is a bat file I am putting together to accomplish different tasks I commonly use CMD for. Not all this code originated with me. Though none of it has a copyright or patent associated with it(as far as I am aware)
::
::

::Set this bat files CMD window title
title ???

::checks to see if the bat was started as admin. As it doesn't work well under that condition(really need to know how to do this right)
IF "%cd%" == "%HOMEDRIVE%\WINDOWS\system32" goto adminwarn
GOTO exit
::GOTO menu ::for a menu that likely doesn't work right
::GOTO appdata ::for minecraft launchers. Mainly
::GOTO server ::for minecraft servers. Mainly.
::GOTO list ::creates a timestamped file with a list of the current directories contents in it(useful for modlists)
::GOTO rename ::buggy. renames files in a directory. currently causes multiple appends.
::GOTO terraria ::for running a main terraria server, and a temp one side by side.
::GOTO palworld

:exit
::mainly here so pause isn't all over the place.
@ECHO OFF
ECHO End of BAT file Reached
PAUSE
ENDLOCAL
EXIT

:adminwarn
ECHO ERROR: RUN.bat was ran as administrator. Early program termination triggerd. Exiting now.
pause
ENDLOCAL
@ECHO off
EXIT

:menu
::CHOICE [/c [choiceKeys]] [/N] [/CS] [/t Timeout /D Choice] [/M "Text"]
::this should be set up to choose a palworld server
::it will delete some stuff then try to copy other stuff. if not setup corrently it will delete stuff you wanted
CHOICE /c 123 /t 30 /D 3 /M "Press [1]260726 [2]260807 [3]Exit"
If %ERRORLEVEL% EQU 3 goto exit
If %ERRORLEVEL% EQU 2 goto 260807
If %ERRORLEVEL% EQU 1 goto 260726

:appdata
::This is setup for launchers to keep as much of there data in the current directory as possible
set APPDATA=%cd%
start javaw -Xmx128M -jar "name.jar"
goto exit

:server
@ECHO on
:: To stop a minecraft server type "save-all" then "stop"
java -Xmx4G -jar "name.jar" nogui
goto exit

:list
:: Create a file listing the contents of a directory
DIR/B/W *.jar.d >>"%date:~10,4%%date:~7,2%%date:~4,2%-%time:~0,2%%time:~3,2%.txt"
goto exit

:rename
:: renames the files in the current directory. Using the parameters given.
:: BUGGY:Currently adds .jar to the end of the file. need to change that. I forget how though.
ren *.jar.d *.jar
GOTO exit

:terraria
::Terraria needs its own section
::This will launch two servers. One begins the main play server. The other a temp server.
::Warning: Temp server is deleted every time this file is ran. And a new one created.
::Warning: This brings my computer to its knees when it is run
start TerrariaServer.exe -config "main.cfg"
IF EXIST ".\Worlds\tmp*" DEL ".\Worlds\temp*"
::start TerrariaServer.exe -config "temp.cfg"
::To stop a terria server type in "save", press enter, then "exit", and press enter.
GOTO exit

:palworld
:260726
CD ".\Palworld"
IF EXIST ".\Pal\Saved\Config\WindowsServer\*" DEL /Q ".\Pal\Saved\Config\WindowsServer\*"
COPY ".\Pal\Saved\SaveGames\0\2607261232\WindowsServer" ".\Pal\Saved\Config\WindowsServer"
start PalServer.exe -port=8311 -nosteam
GOTO exit
:260807
CD ".\Palworld"
IF EXIST ".\Pal\Saved\Config\WindowsServer\*" DEL /Q ".\Pal\Saved\Config\WindowsServer\*"
COPY ".\Pal\Saved\SaveGames\0\260807\WindowsServer" ".\Pal\Saved\Config\WindowsServer"
start PalServer.exe -port=8311 -nosteam
GOTO exit

ECHO Wrong End Reached
PAUSE
EXIT
::Credits:
::http://ss64.com/ (The information on the site has helped me vastly in figuring out how to do what I want to do)
::google (helps with finding example lines for formatting)
::Thanks to all those out there that every provided a example bit of code.
::Thanks "SeeMoreGain" on stackexchange (for posting a example filename to another's question on there)
::Thanks Himeki, they pointed me towards how to code the terraria portion. They know a ton more about terraria then I do (they also said that placing a link to a bat file in "\AppData\Roaming\Microsoft\Windows\SendTo" will add the bat to the list of items in the send to menu.)