2

I need to shutdown a program (minecraft server). I think taskkill will do the job

@echo on
TASKKILL /F /IM Minecraft server /T
echo killed!

I asked questions before of how to auto type "stop" in the console of the server, but they didn't work. I don't want to download any extra programs. Just batch, VBScript, or Java. I would prefer batch though.

Hope I made some sense anyway thanks!

Community
  • 1
  • 1
TylerTotally
  • 113
  • 1
  • 2
  • 9
  • minecraft_server.exe is just a wrapper for a bunch of Java files. When you run it, the only new program that appears in the Tasklist is `javaw.exe`. If you aren't running any other Java programs at the same time as the Minecraft server, you can kill `javaw.exe`. – SomethingDark May 30 '15 at 01:33
  • 1
    You really don't want to `taskkill` your Minecraft server to stop it. There is a very high chance you will corrupt your world. – Ryan Bemrose May 30 '15 at 04:03
  • Edit for formatting. Links to referenced questions. Words – Ryan Bemrose May 30 '15 at 04:36

2 Answers2

1

I think you're looking for this:

@echo off
for /f "tokens=2" %%a in ('tasklist^|find /i "javaw.exe"') do (set pid=%%a)
echo %pid%
taskkill /pid %pid%
pause

This will get the PID (temporary "ID" for a proccess/task), and kill it/the source. This will take a random "javaw.exe" though, so if you have more than one 'javaw.exe' / java proccess open at a time, it will take a random one, find its' PID and kill it. But as for my experience when running a Minecraft server you dont want to have many unnessecary programs open in the Background - so you can safely use this as long as you only run one 'javaw.exe' at a time :)

Hope this help!

Albert MN.
  • 713
  • 1
  • 16
  • 33
0

The correct Syntax for Taskkill

taskkill [/s Computer] [/u Domain\User [/p Password]]] [/fi FilterName] [/pid ProcessID]|[/im ImageName] [/f][/t]

To kill Minecraft Server

TaskKill /F /IM javaw.exe

Hope this Helps.

0m3r
  • 12,286
  • 15
  • 35
  • 71