Search code examples
batch-filejbossjboss-cli

JBoss: How to ignore Press any key to continue, without editing the jboss-cli.bat?


We are trying to read the JBoss status using the jboss-cli.bat command.

jboss-cli.bat -c --command=":read-attribute(name=server-state)" > "$env:JBOSS_HOME\JbossServerStatus.txt"

Storing the status in the TXT file. Since "Press any key to continue" occurs, the controller doesn't return back.

Is there any way to ignore the Press any key to continue without editing the jboss-cli.bat? We know that by adding set NOPAUSE = true, will avoid this problem, but we are looking for solution without editing the file.


Solution

  • The jboss-cli.bat includes a line as

     if "x%NOPAUSE%" == "x" pause
    

    so, we only need to declare a environment variable called NOPAUSE and set it to some value before calling the jboss-cli.bat

    set "NOPAUSE=true"
    jboss-cli.bat .....
    

    If the joss-cli.bat is being called from a powershell script (from comments), then we will need to use something like

    $env:NOPAUSE = "true"
    .\jboss-cli.bat .....