I have no idea where to start on this one. I have seen answers that are like this but I don't know how to format them for what I want. I just need to target the minecraft server while its open and close it by typing "stop" in the console. I have no code to show for but this will be in a other file so I can launch it and then have it close the program. btw I don't think I can use taskkill
But anything will help ;) thankyou very much!

- 113
- 1
- 2
- 9
-
Have you looked at [`mcrcon`](https://bukkit.org/threads/admin-rcon-mcrcon-remote-connection-client-for-minecraft-servers.70910/)? – Frxstrem May 29 '15 at 22:16
3 Answers
This is not possible using a batch file alone. There are two main ways to get input to another program in the system (in this case, java.exe):
- Get your program to listen for a special signal. There are several administrative plugins for Minecraft which will run in the Java process and will do what you need.
- Spoof user input to the program. In the case of a console app, you would probably use a SendKeys() based solution. See How to send input to the console as if the user is typing for some examples.
In the case of Minecraft, I think the first solution is going to be significantly easier, because the modding community has already supplied a number of solutions to this exact problem. @Frxstrem recommended mcrcon, which I suppose is as good a solution as any.

- 9,018
- 1
- 41
- 54
Most probably the console client you are using is scriptable and this is not good aproach.
Any way here's a sendKeys.bat. You can use it like:
call sendKeys.bat "Minecraft console title" "stop{enter}"

- 55,367
- 18
- 148
- 187
Batch files can't do this without calling out to something else; if you're going to call to something else, use AutoHotkey - that's what it's good at.
WinActivate "the title of the Minecraft server window"
https://www.autohotkey.com/docs/commands/WinActivate.htm
Send stop{Enter}

- 27,511
- 4
- 48
- 87
-
Thankyou sll for responding so quickly I even had enough time to make icecream and I refreshed the page and BAM now my program works great thanks you guys! ;) – TylerTotally May 29 '15 at 23:09