Program to Restart server after sending a command to a java cmd prompt

Odpovědět Program to Restart server after sending a command to a java cmd prompt

  • 5. května 2012 17:31
     
     
    Hi basicly i want to create a .bat or something that sends a command to an already running java command prompt waits for a response from the prompt and then tells the server to restart. I run windows server 2008 R2 and Basicly it has a game server on it that i want to tell to shutdown before the server restarts

Všechny reakce

  • 5. května 2012 17:57
     
      Obsahuje kód
    Hi basicly i want to create a .bat or something that sends a command to an already running java command prompt waits for a response from the prompt and then tells the server to restart. I run windows server 2008 R2 and Basicly it has a game server on it that i want to tell to shutdown before the server restarts

    Who is going to run the batch file?

    Why not just wrap the java on a 'unAsServer" tool from the Resource Kit and use net stop service to shut it down.

    You can try this but it is not rally very reliable.

    Set objShell = WScript.CreateObject("WScript.Shell")                        
    ret=objShell.AppActivate("Java Console Name")
    if Not ret Then
         msgbox "Cannot find a Windows with that name"
    Else
         WScript.Sleep 200
         objShell.SendKeys "exit{enter}"
    End If
    Replace string with name of console (window title) and SendKeys with correct exit commands.

    ¯\_(ツ)_/¯

  • 5. května 2012 18:10
     
     Odpovědět

    Here are three differnt ways to do what you are trying to do.  They all allow you to use net stop/start.

    http://edn.embarcadero.com/article/32068
    http://www.coretechnologies.com/products/AlwaysUp/Apps/RunJavaApplicationAsAService.html
    http://www.devx.com/Java/Article/34438/1954

    Use one of the above methods then you can just do a simple command line restart.

    net stop myjavaapp && net start myjavaapp

    Or put it in a batch file.


    ¯\_(ツ)_/¯


  • 5. května 2012 18:19
     
     
    ill look into these thankyou. but i need to give the server console a specific command that way it saves the game before it shutsdown java. and i was just gonna hook the .bat into taskscheduler
  • 12. května 2012 0:24
    Moderátor
     
     

    As there has been no activity in this thread for a few days, we assume the issue is resolved. We will mark it as "answered" to assist others in similar situations. If you disagree, please reply with further information. You can unmark the answer if you wish. If a reply helped answer your question, please mark it as the answer.


    Richard Mueller - MVP Directory Services