Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert command in already open CMD through a .bat

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?

like image 336
phrogg Avatar asked Oct 18 '22 19:10

phrogg


1 Answers

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

like image 191
npocmaka Avatar answered Oct 27 '22 16:10

npocmaka