Advertisement
JamiePhonic

Advanced Run.bat for minecraft servers

Jun 18th, 2013
2,658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. rem These are the user variables. set them as needed
  3.  
  4. Set Jarname=spigot.jar
  5.  
  6. rem Minimum RAM to allocate to the server (MAX 1024M)
  7. Set MinRam=512M
  8. rem Maximum RAM to allocate on 64 Bit machines (No MAX)
  9. Set MaxRam=2G
  10. rem Maximum RAM to allocate on 32 Bit machines or 64 Bit machines running 32 bit Java (MAX 2048M)
  11. Set MaxRam32=512M
  12.  
  13. rem ---------------------------------------------------------------------------------------------
  14.  
  15. rem Java version variables.
  16. SET JavaVersion=8
  17. SET JavaUpdate=101
  18.  
  19. rem Java install location variables.
  20. rem These should only be changed if java is not installed in the default location
  21. SET Java=C:\Program Files\Java
  22. SET JavaX86=C:\Program Files (x86)\Java
  23.  
  24. rem ---------------------------------------------------------------------------------------------
  25.  
  26. rem System Variables, leave these alone or the script may not run correctly
  27. SET PATH=C:\Windows\System32
  28. SET BINDIR=%~dp0
  29. CD /D "%BINDIR%"
  30. color 7
  31.  
  32. :start
  33. cls
  34.  
  35. if exist .\%Jarname% (
  36. goto detectArch
  37. ) else (
  38. goto noJar
  39. )
  40.  
  41. :detectArch
  42. if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
  43. goto 64Bit
  44. ) else (
  45. goto 32Bit
  46. )
  47.  
  48. :64Bit
  49. if exist "%Java%\jre1.%JavaVersion%.0_%JavaUpdate%" (
  50. color A
  51. Echo.
  52. Echo 64 Bit mode
  53. ping 1.1.1.1 -w 1 >NUL
  54. cls
  55. color 7
  56. "%Java%\jre1.%JavaVersion%.0_%JavaUpdate%\bin\java.exe" -Xms%MinRam% -Xmx%MaxRam% -jar %jarname%
  57. goto end
  58.  
  59. ) else if exist "%JavaX86%\jre1.%JavaVersion%.0_%JavaUpdate%" (
  60. color C
  61. Echo.
  62. Echo Warning! Running in 32 bit mode!
  63. Echo Forge based servers may not work properly if at all in this mode.
  64. Echo Install Java 64 Bit for best performance
  65. ping 2.2.2.2 -w 1 >NUL
  66. cls
  67. color 7
  68. "%JavaX86%\jre1.%JavaVersion%.0_%JavaUpdate%\bin\java.exe" -Xms%MinRam% -Xmx%MaxRam32% -jar %jarname%
  69. goto end
  70.  
  71. ) else (
  72.  
  73. cls
  74. Echo.
  75. Echo Java couldn't be found in either:
  76. Echo "%Java%\jre1.%JavaVersion%.0_%JavaUpdate%"
  77. Echo OR
  78. Echo "%JavaX86%\jre1.%JavaVersion%.0_%JavaUpdate%"
  79. Echo.
  80. Echo Make sure the Java variables on lines 16 and 17 to match
  81. Echo the version and update numbers you have installed
  82. Echo If you still have Java 7, you should update to Java 8
  83. Pause
  84. Exit
  85. )
  86.  
  87. :32Bit
  88. if exist "%Java%\jre1.%JavaVersion%.0_%JavaUpdate%" (
  89. color C
  90. Echo.
  91. Echo 32 bit mode
  92. ping 2.2.2.2 -w 1 >NUL
  93. cls
  94. color 7
  95. "%Java%\jre1.%JavaVersion%.0_%JavaUpdate%\bin\java.exe" -Xms%MinRam% -Xmx%MaxRam32% -jar %jarname%
  96. goto end
  97.  
  98. ) else (
  99.  
  100. cls
  101. Echo.
  102. Echo Java couldn't be found in:
  103. Echo "%Java%\jre1.%JavaVersion%.0_%JavaUpdate%"
  104. Echo.
  105. Echo Make sure the Java variables on lines 16 and 17 to match
  106. Echo the version and update numbers you have installed
  107. Echo If you still have Java 7, you should update to Java 8
  108. Pause
  109. Exit
  110. )
  111.  
  112. :noJar
  113. cls
  114. Echo The JAR file '%Jarname%' could not be found
  115. Echo Please replace '%Jarname%' on line 4 of this file with the name of the jar you have.
  116. pause
  117. exit
  118.  
  119. :end
  120. cls
  121. color E
  122. Echo.
  123. Echo STOPPED! CLOSE NOW TO STOP FULLY!
  124. Echo.
  125. Echo Script Written By Jamiephonc. PM on FTB or Spigot forums for support.
  126. ping 1.1.1.1 -w 5 >NUL
  127. ping 2.2.2.2 -w 5 >NUL
  128. goto start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement