I need to know the status of a service at the end of my batch script which restarts services using \"net stop thingie\" and \"net start thingie\".
In my most favorite id
my intention was to create a script which switches services ON and OFF (in 1 script)
net start NameOfSercive 2>nul if errorlevel 2 goto AlreadyRunning if errorlevel 1 goto Error
...
Helped a lot!! TYVM z666
but when e.g. service is disabled(also errorlevel =2?)it goes to "AlreadyRuning"and never comes to
if errorlevel 1 goto Error ?!!
i wanted an output for that case ...
:AlreadyRunning net stop NameOfSercive if errorlevel 1 goto Error :Error Echo ERROR!!1! Pause
my 2 Cents, hope this helps