Page 1 of 1

Unable to come out of the start command in a batch file

Posted: 28 Aug 2015 11:55
by Ram
Hi All,

I am trying to test the service which is running or not, hence wrote the below code. It running fine till starting the webpage, after which its not going to the next command (i.e., line number 4). Can someone pls help me to crack it.

Code: Select all

sc \\server_name query ActiveMQ | find /I "STATE" | find "RUNNING"
if errorlevel 1 goto end
sc \\server_name | start http://localhost:1234/

if errorlevel 1 goto end
echo URL is running
goto success
:success
echo Activmq running fine
:end
echo **Error
echo %date% %time% -- Stopping the services - END


Thanks in advance :) Quick response is appreciable.

Re: Unable to come out of the start command in a batch file

Posted: 28 Aug 2015 16:00
by Squashman
Why are you trying to pipe the sc command to the start command?

Re: Unable to come out of the start command in a batch file

Posted: 28 Aug 2015 18:29
by ShadowThief
Does the script continue when you close the web page?

Re: Unable to come out of the start command in a batch file

Posted: 28 Aug 2015 21:54
by Ram
it is not working, if i give like below

Code: Select all

sc \\server_name start http://localhost:1234/

Re: Unable to come out of the start command in a batch file

Posted: 28 Aug 2015 21:56
by Ram
After i closed the webpage, i need to press enter in cmd prompt window to make this script to run further.

Re: Unable to come out of the start command in a batch file

Posted: 29 Aug 2015 07:29
by Squashman
Ram wrote:it is not working, if i give like below

Code: Select all

sc \\server_name start http://localhost:1234/

Because that is not VALID syntax for the SC command.