Simple Instructions: 1.3 Setup (MC 1.17.1 or newer, Windows, Start Script) - GeheimagentNr1/AutoRestart GitHub Wiki

In this example, we suppose, that you installed the Minecraft server in the directory "C:\servers\Minecraft Server\" and use the Minecraft version 1.18.1 and the Forge version 39.0.17.

First, you create a file named start.cmd in the "C:\servers\Minecraft Server\" directory.
Next, you insert the start script into the start.cmd file:

cd "<Path of your Minecraft server>"
start java -Xmx<Amount of RAM in gigatytes you want to allocate to Minecraft>G @libraries/net/minecraftforge/forge/<Minecraft version>-<Forge version>/win_args.txt

In our example we give the Minecraft server 6 GB RAM to use, with the directory "C:\servers\Minecraft Server\", Minecraft version 1.18.1 and Forge version 39.0.17 it would look like this:

cd "C:\servers\Minecraft Server\"
start java -Xmx6G @libraries/net/minecraftforge/forge/1.18.1-39.0.17/win_args.txt

Last, we have to feed the configuration file named auto_restart-server.toml. It is located in the world\serverconfig directory in the installation directory of your server. In our example, is in the directory "C:\servers\Minecraft Server\world\serverconfig".
In the config file, we have to set use_external_restart_script to false and restart_command to "<Path of your Minecraft server>\start.cmd". (All "\" have to be "\\".)

#Options for restarting:
[restart]
	#Is the server started by an external restart script?
	use_external_restart_script = false
	#Command that is executed on Server stopped to restart the server. Only called if "[restart, use_external_restart_script]" is false.
	restart_command =  "<Path of your Minecraft server>\\start.cmd"

In our example, it would look like this:

#Options for restarting:
[restart]
	#Is the server started by an external restart script?
	use_external_restart_script = false
	#Command that is executed on Server stopped to restart the server. Only called if "[restart, use_external_restart_script]" is false.
	restart_command =  "C:\\servers\\Minecraft Server\\start.cmd"

Now we can start the Minecraft server and the Minecraft server restarts, if you use the /restart command.

After testing that the Minecraft server can restart, we continue configuring the features of the Auto Restart mod, starting with the mod naming Auto Restart feature.
Auto Restart Feature