Wow, that's a boatload of switches. Is all that really necessary?
Also, why waste time doing the architecture check if you are going to make two separate batch files, one for 32 and one for 64? It'd be far more logical to check it then set variables as needed. Also I get why you are doing the bindir thing, but you can't guarantee that the batch file will be in the MC server folder. I know I don't want my server folder in the path, and I'd be putting this batch in the path so I wouldn't use the path to the batch as the place to go.
Also, for 32 bit processor_architecture won't be x32 it's x86. Speaking of x86, bear in mind that using processor_architecture alone isn't totally reliable. My system is 32 bit but the processor_architecture var says x86. You need to also check for processor_architew6432 which on my system correctly returns AMD64.
I'd do it like this, personally:
@echo off setlocal set "config=%~1" rem *********************************** rem CONFIGURATION: rem set defaultConfig=s11 set autoRestart=Y if "%config%"=="" set config=%defaultConfig% if /i "%config%"=="s11" ( set serverName=Sylvcraft's 1.11.2 Server set serverPath=d:\games\minecraft\spigot111 set serverJar=spigot-1.11.2.jar set ramInitial64=8G set ramMax64=12G set ramInitial32=512k set ramMax32=1G ) if /i "%config%"=="s10" ( set serverName=Sylvcraft 1.10.2 Server set serverPath=d:\games\minecraft\spigot110 set serverJar=spigot-1.10.2.jar set ramInitial64=4G set ramMax64=4G set ramInitial32=512k set ramMax32=1G ) if /i "%config%"=="tl" ( set serverName=Sylvcraft TekkitLite Server set serverPath=d:\games\minecraft\tl set serverJar=tekkitlite.jar set ramInitial64=4G set ramMax64=8G set ramInitial32=512k set ramMax32=1G ) rem rem *********************************** if "%serverJar%"=="" goto :failed title %serverName% cd /d "%serverPath%" if /i "%processor_architecture%"=="x86" ( if /i "%processor_architew6432%"=="x86" ( set rI=%ramInitial32% set rM=%ramMax32% set dSwitch=32 ) else ( set rI=%ramInitial64% set rM=%ramMax64% set dSwitch=64 ) ) else ( set rI=%ramInitial64% set rM=%ramMax64% set dSwitch=64 ) :start rem java -Xms%rI% -Xmx%rM% -Xnoclassgc -XX:MaxPermSize=128M -XX:UseSSE=3 -XX:+UseFastAccessorMethods -XX:+OptimizeStringConcat -XX:LargePageSizeInBytes=2M -XX:+UseLargePages -XX:+UseLargePagesInMetaspace -XX:SurvivorRatio=16 -XX:-UseGCOverheadLimit -XX:+UseAdaptiveGCBoundary -XX:+CMSParallelRemarkEnabled -XX:ParallelGCThreads=15 -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=45 -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:InitiatingHeapOccupancyPercent=10 -XX:G1MixedGCLiveThresholdPercent=50 -XX:+AggressiveOpts -verbose:gc -Xloggc:gc.log -d%dSwitch% -jar %serverJar% nogui java -Xms%rI% -Xmx%rM% -jar %serverJar% nogui if /i "%autoRestart%"=="y" ( echo. echo The server has been stopped. echo. choice /c yn /m "Do you wish to restart? (Y/N)" /n /t 3 /d y if errorlevel 2 goto :eof if errorlevel 1 goto :start ) goto :eof :failed echo The config option (%config%) is not valid! goto :eof
I remarked the crazy switched version because Java was complaining about the switches on my box. Personally, I've had no problems with the more slim version I used above.
1
Hello everyone, today I am here, doing my first post in the Minecraft Forum, to bring you the best updated .bat that for certain I, say "I rode" these last few days to my Minecraft Spigot server that I am Recently creating, searching everywhere by Google.
It has been tested for versions 1.5.2 through to version 1.11.1 of Minecraft, (versions below that are outdated, so they will not work) and it is for Windows. (Use at your own risk, I will not be liable for any imcompatibility or general damage to your computer or server. I recommend that you back up your current server files before testing, for safety!) (But do not worry, it's safe, there's no virus or something.)
This .bat is for you to optimize your server performance in a very positive way! It is very fast and efficient.
Here we go:
For 32-bit processors:
@Echo OFF
title (your server name)
SET BINDIR=%~dp0
CD /D "%BINDIR%"
java -version
java -Xmn512M -Xms1G -Xmx1G -Xnoclassgc -XX:MaxPermSize=128M -XX:UseSSE=3 -XX:+UseFastAccessorMethods -XX:+OptimizeStringConcat -XX:LargePageSizeInBytes=2M -XX:+UseLargePages -XX:+UseLargePagesInMetaspace -XX:SurvivorRatio=16 -XX:-UseGCOverheadLimit -XX:+UseAdaptiveGCBoundary -XX:+CMSParallelRemarkEnabled -XX:ParallelGCThreads=15 -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=45 -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:InitiatingHeapOccupancyPercent=10 -XX:G1MixedGCLiveThresholdPercent=50 -XX:+AggressiveOpts -verbose:gc -Xloggc:gc.log -d32 -jar (spigot or bukkit).jar nogui -o (false or true)
PAUSE
For 64-bit processors:
@Echo OFF
title (your server name)
SET BINDIR=%~dp0
CD /D "%BINDIR%"
java -version
IF /I "%PROCESSOR_ARCHITECTURE:~-2%"=="64" java -Xmn512M -Xms1G -Xmx1G -Xnoclassgc -XX:MaxPermSize=128M -XX:UseSSE=3 -XX:+UseFastAccessorMethods -XX:+OptimizeStringConcat -XX:LargePageSizeInBytes=2M -XX:+UseLargePages -XX:+UseLargePagesInMetaspace -XX:SurvivorRatio=16 -XX:-UseGCOverheadLimit -XX:+UseAdaptiveGCBoundary -XX:+CMSParallelRemarkEnabled -XX:ParallelGCThreads=15 -XX:+AlwaysPreTouch -XX:+DisableExplicitGC -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=45 -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:InitiatingHeapOccupancyPercent=10 -XX:G1MixedGCLiveThresholdPercent=50 -XX:+AggressiveOpts -verbose:gc -Xloggc:gc.log -d64 -jar (spigot or bukkit).jar nogui -o (false or true)
PAUSE
(Supports the Java 7 and the Java 8!)
Well, that's all, if you have any questions, talk to me, I'll be updating this post as soon as possible. See you soon and have a good day and thanks for all! xD
(Sorry for my bad English, I'm Portuguese! D:)
I strongly hope I have helped you in something!
If you liked this, please leave your beautiful vote! :3