0

We are trying to Start the WILDFLY Server using the powershell script. Here is the code

cmd.exe /c $env:JBOSS_HOME\bin\standalone.bat

write-host "Before Condition Check"

if ($?)
    {
        write-host "WILDFLY Server STARTED....."
    }
    else
    {
        $JBossResult = "FAILED"
        write-host "Error While Starting WILDFLY Server"
    }

The server is getting started successfully without any issue, but thing is that it is not coming out of the terminal, hence my next part of the code is not getting executed.

Is there anyway to come out of the terminal without stopping the server, so that I continue to my next step.

Chandru M
  • 133
  • 1
  • 7

1 Answers1

1

Replace this:

cmd.exe /c $env:JBOSS_HOME\bin\standalone.bat

with this:

start-process -filepath "$env:JBOSS_HOME\bin\standalone.bat"

Launching cmd.exe directly causes the script to wait for it to exit before continuing.

CodedBeard
  • 862
  • 8
  • 19
  • It is working locally, but when the same script is being called from another machine using invoke command, the server is not getting started. Script Name: JBossStart.PS1 Invoke Command ' Invoke-Command -Session $session -command "JBossStart.PS1" ' It is successfully invoking the script, but the server is not getting started. Any idea how to resolve it? – Chandru M Apr 12 '17 at 11:55
  • Are you sure that the `$env:JBOSS_HOME` actually works when called inside a remote session, try replacing it with a hard coded path to test it. you could also wrap your script with a `start-transcript` and `stop-transcript` which will write out what happened to a log file. – CodedBeard Apr 12 '17 at 12:13
  • FWIW WildFly 10.1.0.Final does have ps1 scripts included. You can see them here https://github.com/wildfly/wildfly-core/tree/2.2.1.Final/core-feature-pack/src/main/resources/content/bin if you want to have a look. – James R. Perkins Apr 13 '17 at 15:33