[Question] How to use Task Scheduler to use the restart scripts while keeping console windows open?
Nycto97 opened this issue · 4 comments
Description
So for hours upon hours I've tried using Task Scheduler to run restart_start.cmd while also keeping the cmd window open + opening the actual server console.
Manually running restart_start.cmd DOES open a cmd window and it opens the server console when the server is launched, allowing me to input commands in the cmd console to control the server.
I'm able to wake pc from sleep and successfully run the script with Task Scheduler, but the problem is that it always launches the server without any window opening. The only place I can see the server is in Task Manager. Ending the task here will automatically restart the process so I need to go in-game every time to shutdown the server.
I've tried many things, including using /k in some places, but nothing works.
Do you have any idea how I can achieve this? Can I replace the cmd scripts with bat scripts to be able to use the /k argument?
Any help is much appreciated!
restart_start.cmd:
cd "G:\Program Files\Minecraft\versions\1.19.2-forge-43.3.7\Server Nycto\"
start .\restart_loop.cmd
restart_loop.cmd:
echo OFF
:start
title Minecraft Server
"C:\Program Files\Eclipse Adoptium\jdk-17.0.10.7-hotspot\bin\java.exe" @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.19.2-43.3.7/win_args.txt %*
SET /p should_restart=<./auto_restart/restart
if %should_restart% EQU 0 goto stop
echo If you want to stop the server completely, press CTRL-C, \before the countdown is at 1!
echo Rebooting in:
timeout /T 3 /nobreak
echo "==================================================="
echo "==================================================="
echo "==================================================="
echo "=============== RESTARTING SERVER ==============="
echo "==================================================="
echo "==================================================="
echo "==================================================="
goto start
:stop
config:
#Options for restarting:
[restart]
#Is the server started by an external restart script?
use_external_restart_script = true
#Command that is executed on Server stopped to restart the server. Only called if "[restart, use_external_restart_script]" is false.
restart_command = ""
#Option for auto restarting:
[auto_restart]
#Should the Server do automatic restarts?
enabled = true
#Times in 24-hour format on which the server will automatically restart
times = ["08:00"]
#Should the server be automatically restarted when it crashes.
on_crash = true
#Times before an auto restart of the server, a restart warning should be shown.
#Examples:
# - 5s - For a message 5 seconds before a restart
# - 7m - For a message 7 minutes before a restart
# - 2h - For a message 2 hours before a restart
warning_times = ["30s", "20s", "15s", "10s", "5s", "4s", "3s", "2s", "1s"]
#Options for restart, if the server is empty:
[on_empty_restart]
#Should the server restart, if no players are online?
enabled = false
#Delay after the server should restart, if it is empty.
#Examples:
# - 5s - For a delay 5 seconds
# - 7m - For a delay 7 minutes
# - 2h - For a delay 2 hours
delay = "10m"
#Options for restart, if the tps of server or its dimensions are low:
[low_tps_restart]
#Should the server restart, if it is below a tps level for a specified time?
enabled = false
#TPS level below which the server is restarted, if it lasts for a specified time.
#Range: 0.0 ~ 20.0
minium_tps_level = 0.0
#Delay, that the server must be below the defined TPS level, in order for it to be restarted.
#Examples:
# - 5s - For a delay 5 seconds
# - 7m - For a delay 7 minutes
# - 2h - For a delay 2 hours
delay = "1m"
References (optional)
No response
Additional info (optional)
No response
This issue/pull request has been automatically closed because it has not had activity in a long time.
Hi,
I found two ways that you could try:
- Use the /interactive flag in the Task Scheduler:
First answer: https://serverfault.com/questions/327491/how-to-make-the-task-scheduler-display-the-cmd-shell-when-invoking-a-batch-file
https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-2000-server/bb726974(v=technet.10)?redirectedfrom=MSDN - 3te answer: https://serverfault.com/questions/327491/how-to-make-the-task-scheduler-display-the-cmd-shell-when-invoking-a-batch-file
The last thing, that you could try, is to put a shortcut or a batch file into the auto start folder of windows.
Thank you so much! I will try it when I have the time for it and let you know if it worked :)