Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ECHO OFF
- SETLOCAL
- ::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 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.
- :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
- :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
- 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.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement