Guest User

Console Master Batch

a guest
May 29th, 2017
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Winbatch 12.26 KB | None | 0 0
  1. @echo off
  2. set consolename=Console Master
  3. set consoleVersion=1.0
  4. set prefix=%consoleName% %consoleVersion%
  5.  
  6. :::::::: Description ::::::::
  7. :: Based on Airbornz's Better Console program, just reimagined and made to fit the needs of ANY Minecraft Server, and even added Ngrok support!
  8. :: This is an open source program, feel free to copy but you must leave proper credit!
  9. :: Tested on Windows 10
  10.  
  11. ::First thing to start up, checks for any files created by Console Master
  12. :boot
  13. title %prefix%
  14. if not exist cmJar.txt goto setup
  15. if not exist cmMCVersion.txt goto setup
  16. if exist cmColor.txt set /p color=<cmColor.txt
  17. set /p jarfile=<cmJar.txt
  18. set /p mcversion=<cmMCVersion.txt
  19. goto core
  20.  
  21. ::First time setup menu, the user enters the server basic information here
  22. :setup
  23. title %prefix%: Setup (Jar: N/A, MC N/A)
  24. cls
  25. echo Welcome To %consoleName%!!
  26. echo.
  27. echo Let me ask get to know your server better
  28. echo.
  29. set /p jarfile="Your Server's .jar File w/o the Extension: "
  30. echo %jarfile%>>cmJar.txt
  31. title %prefix%: Setup (Jar: %jarfile%, MC N/A)
  32. set /p mcversion="Your Server's Minecraft Version: "
  33. echo %mcversion%>>cmMCVersion.txt
  34. title %prefix%: Setup (Jar: %jarfile%, MC %mcversion%)
  35. echo java -Xms1G -Xmx1G -jar %jarfile%.jar -o true>>cmRam.txt
  36. echo.
  37. goto setupColorSelection
  38.  
  39. ::The user is asked if they want to add in custom colors
  40. :setupColorSelection
  41. echo Would you like to use custom coloring?
  42. set /p cmd="Y or N: "
  43. if %cmd%==Y goto colorSetup
  44. if %cmd%==y goto colorSetup
  45. if %cmd%==N goto promptFinishCore
  46. if %cmd%==n goto promptFinishCore
  47. cls
  48. echo Invaild Option (%cmd%)
  49. pause
  50. goto setupColorSelection
  51.  
  52. ::Tells the user that they are done and that they will move on to the main menu after 5 seconds (or they can skip the wait by pressing any key)
  53. :promptFinishCore
  54. echo.
  55. echo You're done with the basic setup!
  56. echo.
  57. echo Moving to main menu...
  58. TIMEOUT 5
  59. goto core
  60.  
  61. ::The console's main menu
  62. :core
  63. title %prefix% : Main Menu (Jar: %jarfile%, MC %mcversion%)
  64. cls
  65. echo Welcome to %prefix%!!
  66. echo.
  67. echo Options:
  68. echo.
  69. echo 1. Start The Server
  70. echo 2. Settings
  71. echo 3. Exit
  72. echo.
  73. echo Enter The Number Of Your Choice.
  74. echo.
  75. set /p cmd="Command ID: "
  76. if %cmd%==1 goto start
  77. if %cmd%==2 goto set
  78. if %cmd%==3 exit
  79. cls
  80. echo Invaild Option (%cmd%)
  81. pause
  82. goto core
  83.  
  84. ::First phase of the server startup sequence, sepeated so Ngrok can be checked
  85. :start
  86. title %prefix% : Minecraft Server Running
  87. cls
  88. echo ------------------ START OF SERVER LOG ------------------
  89. echo [%consolename%]: Server Starting!
  90. goto checkForNGrok
  91.  
  92. ::Second and final phase of the server startup sequence, begins to log the server output here
  93. :start2
  94. echo [%consolename%]: Loading Java Arguments To Use!
  95. set /p arg=<cmRam.txt
  96. echo [%consolename%]: Done Loading! Starting Server Now!
  97. %arg%
  98.  
  99. ::Server stop sequence, intial phase
  100. :stop
  101. title %prefix%: Minecraft Server Stopped
  102. echo [%consolename%]: Server Stopped Check Above For Details!
  103. echo ------------------ END OF SERVER LOG ------------------
  104. goto promptExit
  105.  
  106. ::Checks to see if Ngrok is opened or not
  107. :checkForNGrok
  108. echo [%consolename%]: Checking for Ngrok process...
  109. tasklist /FI "imagename eq cmd.exe" /FI "WINDOWTITLE eq %prefix% - ngrok  tcp 25565" |find "cmd.exe" > nul
  110. if %ERRORLEVEL% == 0 goto runningNgrokAlready
  111. if %ERRORLEVEL% == 1 goto startNGrok
  112. goto error
  113.  
  114. ::Starts up Ngrok if checkForNGrok is 0 (meaning that the cmd is NOT open) then moves on to the final server startup sequence
  115. :startNGrok
  116. echo [%consolename%]: Ngrok not active! Starting Ngrok...
  117. start "%prefix%" cmd /k "ngrok tcp 25565"
  118. echo [%consolename%]: Ngrok Started!
  119. goto start2
  120.  
  121. ::Skips startup for Ngrok if checkForNGrok is 1 (meaning that the cmd IS open) then moves on to the final server startup sequence
  122. :runningNgrokAlready
  123. echo [%consolename%]: Ngrok is Already Running! Skipping Ngrok Startup..
  124. goto start2
  125.  
  126. ::Asks if the user wants to restart the server after the server stops
  127. :promptExit
  128. echo [%consolename%]: Would you like to restart the server?
  129. set /p cmd="Y or N: "
  130. if %cmd%==Y goto start
  131. if %cmd%==y goto start
  132. if %cmd%==N goto endServer
  133. if %cmd%==n goto endServer
  134. cls
  135. echo Invaild Option (%cmd%)
  136. pause
  137. goto promptExit
  138.  
  139. ::If the user said 'n' for promptExit, begin to exit out of the server sequence, asking rather to close the console or keep it open
  140. :endServer
  141. title %prefix%: Confirm Exit
  142. cls
  143. echo Ok, would you like to exit out of %consoleName%?
  144. set /p cmd="Y or N: "
  145. if %cmd%==Y goto endConsolePrompt
  146. if %cmd%==y goto endConsolePrompt
  147. if %cmd%==N goto endNgrokPrompt
  148. if %cmd%==n goto endNgrokPrompt
  149. cls
  150. echo Invaild Option (%cmd%)
  151. pause
  152. goto endServer
  153.  
  154. ::If the user said 'y' for endServer, asks to close Ngrok along with the console or keep Ngrok open and just close the console
  155. :endConsolePrompt
  156. echo Ok, would you like to exit Ngrok aswell?
  157. set /p cmd="Y or N: "
  158. if %cmd%==Y goto killNgrok
  159. if %cmd%==y goto killNgrok
  160. if %cmd%==N goto killConsole
  161. if %cmd%==n goto killConsole
  162. cls
  163. echo Invaild Option (%cmd%)
  164. pause
  165. goto endConsolePrompt
  166.  
  167. ::If the user said 'n' for endServer, asks to ONLY close Ngrok or keep it open
  168. :endNgrokPrompt
  169. echo Ok, would you like to exit Ngrok?
  170. set /p cmd="Y or N: "
  171. if %cmd%==Y goto killNgrok2
  172. if %cmd%==y goto killNgrok2
  173. if %cmd%==N goto returnToCore
  174. if %cmd%==n goto returnToCore
  175. cls
  176. echo Invaild Option (%cmd%)
  177. pause
  178. goto endNgrokPrompt
  179.  
  180. ::Kills Ngrok THEN prompts to close the console
  181. :killNgrok
  182. echo Exiting Ngrok...
  183. @echo off
  184. taskkill /IM cmd.exe /FI "WINDOWTITLE eq %prefix% - ngrok  tcp 25565"
  185. echo Ngrok closed!
  186. goto killConsole
  187.  
  188. ::Kills Ngrok but keeps the console open, making the console return to the main menu
  189. :killNgrok2
  190. echo Exiting Ngrok...
  191. @echo off
  192. @echo off
  193. taskkill /IM cmd.exe /FI "WINDOWTITLE eq %prefix% - ngrok  tcp 25565"
  194. echo Ngrok closed!
  195. goto exitThenReturnToCoreNgrok
  196.  
  197. ::Tells user to press any button to close the console
  198. :killConsole
  199. echo Ok, Press Any Key To Exit!
  200. pause > nul
  201. exit
  202.  
  203. ::Returns the user back to the main menu after server sequence is ended
  204. :returnToCore
  205. echo.
  206. echo Ok, returning back to main menu...
  207. TIMEOUT 5
  208. goto core
  209.  
  210. ::Returns the user back to the main menu after ONLY Ngrok is closed
  211. :exitThenReturnToCoreNgrok
  212. echo.
  213. echo Returning back to main menu...
  214. TIMEOUT 5
  215. goto core
  216.  
  217. ::The settings menu for the console
  218. :set
  219. title %prefix% : Settings
  220. cls
  221. echo Welcome to the Settings Menu!
  222. echo.
  223. echo Settings:
  224. echo.
  225. echo 1. Coloring - Set The Color Scheme
  226. echo 2. Change Minecraft Version - Change What Version of Minecraft the Server is Using
  227. echo 3. RAM Allocation - Set RAM Allocation (Advanced)
  228. echo 4. Custom Arguments - Set custom arguments besides the RAM! (Advanced)
  229. echo 5. Factory Reset [!!]
  230. echo 6. Back To Main Menu
  231. echo.
  232. set /p cmd="Command: "
  233. if %cmd%==1 goto colorSettings
  234. if %cmd%==2 goto newMCVersion
  235. if %cmd%==3 goto ram
  236. if %cmd%==4 goto args
  237. if %cmd%==5 goto reset
  238. if %cmd%==6 goto core
  239. cls
  240. echo Invaild Option (%cmd%)
  241. pause
  242. goto set
  243.  
  244. ::Color selection menu for first-time setup
  245. :colorSetup
  246. cls
  247. echo Enter the color code of your choice.
  248. echo The color codes go as the following format: 0C - where 0 is the background color and A is the text color
  249. echo.
  250. echo The avilable color codes are the following:
  251. echo 0 = Black       8 = Gray
  252. echo 1 = Blue        9 = Light Blue
  253. echo 2 = Green       A = Light Green
  254. echo 3 = Aqua        B = Light Aqua
  255. echo 4 = Red         C = Light Red
  256. echo 5 = Purple      D = Light Purple
  257. echo 6 = Yellow      E = Light Yellow
  258. echo 7 = White       F = Bright White
  259. echo.
  260. echo Please Note: If you some how screw up delete your cmColor.txt file located in the server folder.
  261. echo.
  262. set /p cmd="Color Code: "
  263. del "cmColor.txt"
  264. echo %cmd%>>cmColor.txt
  265. goto concolorSetup
  266.  
  267. ::Saves the color scheme and then goes to main menu (for first time setup)
  268. :concolorSetup
  269. set /p color=<cmColor.txt
  270. cls
  271. echo Color Scheme Set!
  272. echo.
  273. echo Moving to main menu...
  274. TIMEOUT 5
  275. color %color%
  276. goto core
  277.  
  278. ::Color selection menu (Settings Menu Version)
  279. :colorSettings
  280. cls
  281. echo Enter the color code of your choice.
  282. echo The color codes go as the following format: 0C - where 0 is the background color and A is the text color
  283. echo.
  284. echo The avilable color codes are the following:
  285. echo 0 = Black       8 = Gray
  286. echo 1 = Blue        9 = Light Blue
  287. echo 2 = Green       A = Light Green
  288. echo 3 = Aqua        B = Light Aqua
  289. echo 4 = Red         C = Light Red
  290. echo 5 = Purple      D = Light Purple
  291. echo 6 = Yellow      E = Light Yellow
  292. echo 7 = White       F = Bright White
  293. echo.
  294. echo Please Note: If you some how screw up delete your cmColor.txt file located in the server folder.
  295. echo.
  296. set /p cmd="Color Code: "
  297. del "cmColor.txt"
  298. echo %cmd%>>cmColor.txt
  299. goto concolorSettings
  300.  
  301. ::Saves the color scheme and then returns to the settings menu
  302. :concolorSettings
  303. set /p color=<cmColor.txt
  304. cls
  305. echo Color Scheme Set!
  306. goto exitThenReturnToSettingsColor
  307.  
  308. ::Prompts for user to enter new Minecraft Version
  309. :newMCVersion
  310. cls
  311. echo Please enter the new Minecraft Version your server will use
  312. set /p mcversion="Version: "
  313. del "cmMCVersion.txt"
  314. echo %mcversion%>>cmMCVersion.txt
  315. echo.
  316. echo New Minecraft Version Set!
  317. goto exitThenReturnToSettings
  318.  
  319. ::Prompts user to change the amount of RAM allocation
  320. :ram
  321. cls
  322. echo Please Enter Your Minimum Amount Of RAM To Use Followed By 'M' For Megabytes Or  'G' For Gigabytes:
  323. set /p min="Minimum Amount: "
  324. echo.
  325. echo Please Enter Your Maximum Amount Of RAM To Use Followed By 'M' For Megabytes Or  'G' For Gigabytes:
  326. set /p max="Maximum Amount: "
  327. del "cmRam.txt"
  328. echo java -Xms%min% -Xmx%max% -jar %jarfile%.jar -o true>>cmRam.txt
  329. cls
  330. echo RAM Amounts Set!
  331. goto exitThenReturnToSettings
  332.  
  333. ::Asks user to confirm if they want to change the java arguments and shows them their current ones
  334. :args
  335. cls
  336. echo.
  337. echo This where you can change your java args without opening the file.
  338. echo.
  339. echo [!] This Is For Advanced Users Only! If You Do Not Know How To Use Arguments Do Not Use This!
  340. echo.
  341. set /p args=<cmRam.txt
  342. echo These are your current args:
  343. echo %args%
  344. echo.
  345. echo Would you like to change it?
  346. set /p cmd="Y or N: "
  347. if %cmd%==Y goto cargs
  348. if %cmd%==y goto cargs
  349. if %cmd%==N goto exitThenReturnToSettings
  350. if %cmd%==n goto exitThenReturnToSettings
  351. echo.
  352. echo Invaild Choice! (%cmd%)
  353. pause
  354. goto args
  355.  
  356. ::Prompts user to change java arguments and shows them their original ones
  357. :cargs
  358. cls
  359. echo Ok Please Enter Your New Arguments.
  360. echo For Reference Here Is Your Arguments:
  361. echo.
  362. echo %args%
  363. echo.
  364. echo [!] Make sure to launch the server's jar file in your arguments!!
  365. echo.
  366. set /p nargs="New Arguments: "
  367. cls
  368. echo.
  369. echo Are you sure you want to save these as your new arguments?
  370. echo %args%
  371. echo.
  372. set /p cmd="Y or N: "
  373. if %cmd%==Y then goto sargs
  374. if %cmd%==y then goto sargs
  375. if %cmd%==N then goto cargs
  376. if %cmd%==n then goto cargs
  377. cls
  378. echo.
  379. echo Invaild Choice!
  380. pause
  381. goto cargs
  382.  
  383. ::Saves the new java arguments
  384. :sargs
  385. cls
  386. echo Saving Arguments…
  387. del "cmRam.txt"
  388. echo %nargs%>>cmRam.txt
  389. echo Done!
  390. echo Changing Cached Arguments...
  391. %args% = %nargs%
  392. echo Done!
  393. echo Complete!
  394. echo.
  395. echo Your New Arguments Are Saved And Ready For Use!
  396. goto exitThenReturnToSettings
  397.  
  398. ::Confirm factory reset
  399. :reset
  400. cls
  401. echo Are you SURE you want to reset back to factory default? This process CANNOT be reversed!!
  402. set /p cmd="Y or N: "
  403. if %cmd%==Y then goto confirmReset
  404. if %cmd%==y then goto confirmReset
  405. if %cmd%==N then goto exitThenReturnToSettings
  406. if %cmd%==n then goto exitThenReturnToSettings
  407.  
  408. ::Deletes the settings then returns to first-time setup
  409. :confirmReset
  410. cls
  411. echo Deleting all settings...
  412. if exist cmJar.txt del "cmJar.txt"
  413. if exist cmMCVersion.txt del "cmMCVersion.txt"
  414. if exist cmRam.txt del "cmRam.txt"
  415. if exist cmColor.txt del "cmColor.txt"
  416. echo Factory Reset Completed!
  417. cls.
  418. echo Returning to first-time setup...
  419. TIMEOUT 5
  420. color 07
  421. goto boot
  422.  
  423. ::Applies color then returns to settings menu
  424. :exitThenReturnToSettingsColor
  425. cls
  426. echo Returning back to settings menu...
  427. TIMEOUT 5
  428. color %color%
  429. goto set
  430.  
  431. ::Returns to settings menu WITHOUT applying color
  432. :exitThenReturnToSettings
  433. echo.
  434. echo Returning back to settings menu...
  435. TIMEOUT 5
  436. goto set
  437.  
  438. ::Tells user of error if one occurs
  439. :error
  440. cls
  441. echo An error has occured!!
  442. echo %ERRORLEVEL%
  443. echo %ERROR%
  444. echo Please contact the developer!
  445. pause
Advertisement
Add Comment
Please, Sign In to add comment