5

I coded a website where my friends can start and close their Minecraft server over PHP. To stop their server, a .bat file kills the process, but normally Minecraft servers will be stopped with the "Stop" command. The Minecraft server is running in a CMD and so my question is:

Is it possible to send a command from a started .bat to a separate, already open CMD so that the already open CMD stop the Server?

SomethingDark
  • 13,229
  • 5
  • 50
  • 55
phrogg
  • 888
  • 1
  • 13
  • 28

1 Answers1

3

You can send keys to the console - but eventually you'll need to know the name of the command prompt window. Check the ready to use sendKeys.bat :

call sendKeys.bat "command prompt" "stop{ENTER}"

in case the title is just command prompt - it could be different so you need to check this.

Default title:

enter image description here

npocmaka
  • 55,367
  • 18
  • 148
  • 187
  • What stands the Command prompt in your example for? The Exact Windowtitle? Because it says everytime that he cannot find the application where i want to input "stop{ENTER}"? – phrogg Dec 29 '15 at 22:41
  • @LuigiTheHunter - `command prompt` is the default title of the console. See my update. – npocmaka Dec 29 '15 at 22:58
  • Ok thanks but its still saying that it cannot find my application. – phrogg Dec 29 '15 at 23:54
  • wtf windows can be scripted using JAVASCRIPT? This is whole new level of fun! :D – Tomáš Zato Jan 11 '16 at 16:52
  • @LuigiTheHunter - mind tat the the windows title is case sensitive – npocmaka Jan 11 '16 at 17:03
  • 1
    @TomášZato - It is not exactly javascript - it's jscript - a microsoft implementation for WSH - ant it can use a lot of the Windows APIs .It's ecmascript 3 implementation - for ecmascript 6 check the the end of the first posted thread. You can take a look at this [thread](http://www.dostips.com/forum/viewtopic.php?t=5543) and [this](http://www.dostips.com/forum/viewtopic.php?t=5260) and [this](http://www.dostips.com/forum/viewtopic.php?t=5526) . – npocmaka Jan 11 '16 at 17:08
  • 1
    Does no one has any idea? – phrogg Sep 14 '16 at 10:18