DeathOfTime

RUN.BAT

Aug 14th, 2026 (edited)
8,340
-1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | Gaming | 0 1
  1. @ECHO OFF
  2. SETLOCAL EnableDelayedExpansion
  3. ::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)
  4. ::
  5. ::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)
  6. ::
  7. ::
  8.  
  9. ::Set this bat files CMD window title
  10. title ???
  11.  
  12. ::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)
  13. IF "%cd%" == "%HOMEDRIVE%\WINDOWS\system32" goto adminwarn
  14. GOTO exit
  15. ::GOTO menu ::for a menu that likely doesn't work right
  16. ::GOTO appdata ::for minecraft launchers. Mainly
  17. ::GOTO server ::for minecraft servers. Mainly.
  18. ::GOTO list ::creates a timestamped file with a list of the current directories contents in it(useful for modlists)
  19. ::GOTO rename ::buggy. renames files in a directory. currently causes multiple appends.
  20. ::GOTO terraria ::for running a main terraria server, and a temp one side by side.
  21. ::GOTO palworld
  22.  
  23. :exit
  24. ::mainly here so pause isn't all over the place.
  25. @ECHO OFF
  26. ECHO End of BAT file Reached
  27. PAUSE
  28. ENDLOCAL
  29. EXIT
  30.  
  31. :adminwarn
  32. ECHO ERROR: RUN.bat was ran as administrator. Early program termination triggerd. Exiting now.
  33. pause
  34. ENDLOCAL
  35. @ECHO off
  36. EXIT
  37.  
  38. :menu
  39. ::CHOICE [/c [choiceKeys]] [/N] [/CS] [/t Timeout /D Choice] [/M "Text"]
  40. ::this should be set up to choose a palworld server
  41. ::it will delete some stuff then try to copy other stuff. if not setup corrently it will delete stuff you wanted
  42. CHOICE /c 123 /t 30 /D 3 /M "Press [1]260726 [2]260807 [3]Exit"
  43. If %ERRORLEVEL% EQU 3 goto exit
  44. If %ERRORLEVEL% EQU 2 goto 260807
  45. If %ERRORLEVEL% EQU 1 goto 260726
  46.  
  47. :appdata
  48. ::This is setup for launchers to keep as much of there data in the current directory as possible
  49. set APPDATA=%cd%
  50. start javaw -Xmx128M -jar "name.jar"
  51. goto exit
  52.  
  53. :server
  54. @ECHO on
  55. :: To stop a minecraft server type "save-all" then "stop"
  56. java -Xmx4G -jar "name.jar" nogui
  57. goto exit
  58.  
  59. :list
  60. :: Create a file listing the contents of a directory
  61. DIR/B/W *.jar.d >>"%date:~10,4%%date:~7,2%%date:~4,2%-%time:~0,2%%time:~3,2%.txt"
  62. goto exit
  63.  
  64. :rename
  65. :: renames the files in the current directory. Using the parameters given.
  66. :: BUGGY:Currently adds .jar to the end of the file. need to change that. I forget how though.
  67. ren *.jar.d *.jar
  68. GOTO exit
  69.  
  70. :terraria
  71. ::Terraria needs its own section
  72. ::This will launch two servers. One begins the main play server. The other a temp server.
  73. ::Warning: Temp server is deleted every time this file is ran. And a new one created.
  74. ::Warning: This brings my computer to its knees when it is run
  75. start TerrariaServer.exe -config "main.cfg"
  76. IF EXIST ".\Worlds\tmp*" DEL ".\Worlds\temp*"
  77. ::start TerrariaServer.exe -config "temp.cfg"
  78. ::To stop a terria server type in "save", press enter, then "exit", and press enter.
  79. GOTO exit
  80.  
  81. :palworld
  82. :260726
  83. CD ".\Palworld"
  84. IF EXIST ".\Pal\Saved\Config\WindowsServer\*" DEL /Q ".\Pal\Saved\Config\WindowsServer\*"
  85. COPY ".\Pal\Saved\SaveGames\0\2607261232\WindowsServer" ".\Pal\Saved\Config\WindowsServer"
  86. start PalServer.exe -port=8311 -nosteam
  87. GOTO exit
  88. :260807
  89. CD ".\Palworld"
  90. IF EXIST ".\Pal\Saved\Config\WindowsServer\*" DEL /Q ".\Pal\Saved\Config\WindowsServer\*"
  91. COPY ".\Pal\Saved\SaveGames\0\260807\WindowsServer" ".\Pal\Saved\Config\WindowsServer"
  92. start PalServer.exe -port=8311 -nosteam
  93. GOTO exit
  94.  
  95. ECHO Wrong End Reached
  96. PAUSE
  97. EXIT
  98. ::Credits:
  99. ::http://ss64.com/ (The information on the site has helped me vastly in figuring out how to do what I want to do)
  100. ::google (helps with finding example lines for formatting)
  101. ::Thanks to all those out there that every provided a example bit of code.
  102. ::Thanks "SeeMoreGain" on stackexchange (for posting a example filename to another's question on there)
  103. ::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