1.

Solve : batch to stop services on multiple servers and then restart same services?

Answer»

I've seen some different postings regarding stopping and starting services and dependencies between services. Here is my need. I have 3 servers with one or two services in question running on each server. I will always know which of the 2 services exist on each server, so that is not an issue. Here is what needs to happen:

Stop IBM Cognos 8 on \\EP App Server
wait for service to stop, then
Stop IBM Cognos 8 Planning 8.4 on \\EP App Server
wait for service to stop, then
Stop IBM Cognos 8 on \\Web Server
wait for service to stop, then
Stop IBM Cognos 8 Planning 8.4 on \\Web Server
wait for service to stop, then
Stop IBM Cognos 8 on \\BI App Server
wait for service to stop, then

Reboot all three servers

Wait for all three servers to start up

Start IBM Cognos 8 on \\BI App Server
wait for service to start, then
Start IBM Cognos 8 on \\EP App Server
wait for service to start, then
Start IBM Cognos 8 Planning 8.4 on \\EP App Server
wait for service to start, then
Start IBM Cognos 8 on \\Web Server
wait for service to start, then
Start IBM Cognos 8 Planning 8.4 on \\Web Server

If possible, then email an output showing that all services started properly. This is not as critical, but would be nice, though.

Notice that the services are started in the reverse order that they are stopped.

I am running Windows 2003 on all three servers.

Let me know what else you need to know...thanks, in advance!First you need to explain:

IBM Cognos 8 Planning 8.4

Here on this forum many are USING Windows server 2003 and the commands are specific to windows.
Does IBM Cognos 8 tun on Windows server 2003?
And does it allow remote control?
can you tell us the service name (Not display name) of IBM Cognos 8 and other service you mentioned. You can find this value when you double click on the service name in services.msc snap in.


Also, I dont think there is a reliable way to "wait for the servers to comeup" from a script. Script can keep pinging the server but ping stars responding as soon as network services are started,does not mean the server is fully up. May be experts here are aware of any way.

Besides that what you asked can be done including emails. May be you can give a approximate time taken by the server for reboot and the script will wait for that much time.



thanks..
Here's what I did that works (still room for improvement, but it works):

ECHO off

REM Script created by Jeff Owen in June 2011 to recycle the Cognos services in the Cognos 8.4 QA environment
REM and to reboot all of the servers in the environment
REM --
REM -- PURPOSE --
REM Cognos Planning performs much of its tasks using java processes constrained by 2G of RAM on each
REM processor, given the 32-bit platform for the Planning applications. Consequently, it is necessary to
REM recycle the services, periodically, to free up the memory for each java process available in the system.
REM This scripts also handles rebooting all of the servers in the environment to further improve
REM performance for the QA environment.

REM -- DOCUMENTATION --
REM This script provides documentation through both the command prompt window (primarily for developing and
REM testing purposes) and a text file for later review. Currently, the text file overwrites itself after
REM each run, on the premise that this will run once or twice a week, so issues will be ID'ed before the next
REM run. Multiple runs will not need to be logged in the file. If this changes, then make sure the first
REM entry to the text file is preceded by >> instead of a single >.


REM ****** ISSUES TO RESOLVE ******
REM what happens if one of the servers does not come back up? this script does not account for this
REM need to change the script to remove the planning services from the GATEWAY server once "production" changes
REM are CARRIED out to QA instance



REM --- stop order for servers ---
REM all planning servers can be stopped at the same time
REM PlanningServer
REM standby content manager
REM active content manager
REM BIServer

REM --- recycle IIS ---
REM stop w3svc
REM start w3svc
REM GatewayServer

REM --- start order for servers ---
REM active content manager
REM BIServer
REM standby content manager
REM all planning servers can be started at the same time
REM PlanningServer

REM --- on individual server with both services ---
REM stop IBM Cognos 8
REM stop IBM Cognos 8 Planning 8.4
REM start IBM Cognos 8 Planning 8.4 (IBM Cognos 8 service is started automatically by starting Planning 8.4)


Echo Planning Recycle started %date% %time% > "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



echo -------------- stopping Cognos services ------------------
echo -------------- stopping Cognos services ------------------ >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on PlanningServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on PlanningServer

:Resolve_PlanningServer_IBMCognos8_pre
REM This is to check the status of this particular service prior to making any changes
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_PlanningServer_IBMCognos 8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_PlanningServer_IBMCognos8_pre

:StopService_PlanningServer_IBMCognos8
echo stop IBM Cognos 8 Service on EP App Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\PlanningServer stop "IBM Cognos 8"

:Resolve_PlanningServer_IBMCognos8_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_PlanningServer_IBMCognos 8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_PlanningServer_IBMCognos8_post

:StoppedService_PlanningServer_IBMCognos 8

REM Show final status before moving on to the next service/server
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on PlanningServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on PlanningServer

:Resolve_PlanningServer_IBMCognos8Planni ng84_pre
REM This is to check the status of this particular service prior to making any changes
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8Pl anning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_PlanningServer_IBMCognos 8Planning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8Pl anning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_PlanningServer_IBMCognos8Planni ng84_pre

:StopService_PlanningServer_IBMCognos8Pl anning84
echo stop IBM Cognos 8 Planning 8.4 Service on EP App Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\PlanningServer stop "IBM Cognos 8 Planning 8.4"

:Resolve_PlanningServer_IBMCognos8Planni ng84_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8Pl anning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_PlanningServer_IBMCognos 8Planning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8Pl anning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_PlanningServer_IBMCognos8Planni ng84_post

:StoppedService_PlanningServer_IBMCognos 8Planning84

REM Show final status before moving on to the next service/server
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"




Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on GatewayServer

:Resolve_GatewayServer_IBMCognos8_pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_IBMCognos8_pre

:StopService_GatewayServer_IBMCognos8
echo stop IBM Cognos 8 Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer stop "IBM Cognos 8"

:Resolve_GatewayServer_IBMCognos8_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_IBMCognos8_post

:StoppedService_GatewayServer_IBMCognos8

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on GatewayServer

:Resolve_GatewayServer_IBMCognos8Plannin g84_pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8Pla nning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_IBMCognos8 Planning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8Pla nning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_IBMCognos8Plannin g84_pre

:StopService_GatewayServer_IBMCognos8Pla nning84
echo stop IBM Cognos 8 Planning 8.4 Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer stop "IBM Cognos 8 Planning 8.4"

:Resolve_GatewayServer_IBMCognos8Plannin g84_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8Pla nning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_IBMCognos8 Planning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8Pla nning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_IBMCognos8Plannin g84_post

:StoppedService_GatewayServer_IBMCognos8 Planning84

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"






Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on BIServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on BIServer

:Resolve_BIServer_IBMCognos8_pre
REM This is to check the status of this particular service prior to making any changes
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_BIServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\BIServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
sc \\BIServer query "IBM Cognos 8" | Find "STATE"
GOTO Resolve_BIServer_IBMCognos8_pre

:StopService_BIServer_IBMCognos8
echo stop IBM Cognos 8 Service on Content Manager / BI App Server Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\BIServer stop "IBM Cognos 8"

:Resolve_BIServer_IBMCognos8_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_BIServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\BIServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_BIServer_IBMCognos8_post

:StoppedService_BIServer_IBMCognos8

REM Show final status before moving on to the next service/server
sc \\BIServer query "IBM Cognos 8" | Find "STATE"







Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo Cognos Services stopped %date% %time% >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo wait 15 seconds >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sleep 15

echo -------------- Reboot Servers ------------------
echo -------------- Reboot Servers ------------------ >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Rebooting all servers in QA simultaneously >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Rebooting all servers in QA simultaneously

shutdown -m \\BIServer -r -t 15 -c "Weekly Maintenance Reboot - Cognos Administrator initiated. Please save and logoff." -f -d p:4:1

shutdown -m \\PlanningServer -r -t 15 -c "Weekly Maintenance Reboot - Cognos Administrator initiated. Please save and logoff." -f -d p:4:1

shutdown -m \\GatewayServer -r -t 15 -c "Weekly Maintenance Reboot - Cognos Administrator initiated. Please save and logoff." -f -d p:4:1

echo wait 90 seconds to ensure all servers are shutting down
sleep 90

:CheckStatus_BIServer
REM This is to check the status of the Event LOG service as a means of determining the server is up and running
SC \\BIServer query "Eventlog" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO CheckStatus_PlanningServer
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\BIServer query "Eventlog" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO CheckStatus_BIServer

:CheckStatus_PlanningServer
REM This is to check the status of the Event Log service as a means of determining the server is up and running
SC \\PlanningServer query "Eventlog" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO CheckStatus_GatewayServer
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "Eventlog" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO CheckStatus_PlanningServer

:CheckStatus_GatewayServer
REM This is to check the status of the Event Log service as a means of determining the server is up and running
SC \\GatewayServer query "Eventlog" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO All_Servers_Started
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "Eventlog" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO CheckStatus_GatewayServer


:All_Servers_Started





echo -------------- Servers Rebooted ------------------
echo -------------- Servers Rebooted ------------------ >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"


echo -------------- stopping and starting World Wide Web Publishing service ------------------
echo -------------- stopping and starting World Wide Web Publishing service ------------------ >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of World Wide Web Publishing Service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of World Wide Web Publishing Service on GatewayServer

:Resolve_GatewayServer_W3SVC_pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_W3SVC
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "W3SVC" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_W3SVC_pre

:StopService_GatewayServer_W3SVC

echo stop World Wide Web Publishing Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer stop "W3SVC"

:Resolve_GatewayServer_W3SVC_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_W3SVC
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "W3SVC" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_W3SVC_post

:StoppedService_GatewayServer_W3SVC

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "W3SVC" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo World Wide Web Publishing Service stopped %date% %time% >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"





echo Status of World Wide Web Publishing service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of World Wide Web Publishing service on GatewayServer

:Resolve_START_GatewayServer_W3SVC_pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_W3SVC
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "W3SVC" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_W3SVC_pre

:StartService_GatewayServer_W3SVC
echo start World Wide Web Publishing Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer start "W3SVC"

:Resolve_START_GatewayServer_W3SVC_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_W3SVC
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "W3SVC" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_W3SVC_post

:StartedService_GatewayServer_W3SVC

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "W3SVC" | Find "STATE"


Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo World Wide Web Publishing Service started %date% %time% >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"




echo -------------- starting Cognos services ------------------
echo -------------- starting Cognos services ------------------ >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on BIServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on BIServer

:Resolve_START_BIServer_IBMCognos8_pre
REM This is to check the status of this particular service prior to making any changes
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_BIServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\BIServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_BIServer_IBMCognos8_pre

:StartService_BIServer_IBMCognos8
echo start IBM Cognos 8 Service on Content Manager / BI App Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\BIServer start "IBM Cognos 8"

:Resolve_START_BIServer_IBMCognos8_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_BIServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\BIServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_BIServer_IBMCognos8_post

:StartedService_BIServer_IBMCognos8

REM Show final status before moving on to the next service/server
sc \\BIServer query "IBM Cognos 8" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on PlanningServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on PlanningServer

:Resolve_START_PlanningServer_IBMCognos8 Planning84_pre
REM This is to check the status of this particular service prior to making any changes
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8P lanning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_PlanningServer_IBMCognos 8Planning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8P lanning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_PlanningServer_IBMCognos8 Planning84_pre

:StartService_PlanningServer_IBMCognos8P lanning84
echo start IBM Cognos 8 Planning 8.4 and IBM Cognos 8 Service on EP App Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\PlanningServer start "IBM Cognos 8 Planning 8.4"

:Resolve_START_PlanningServer_IBMCognos8 Planning84_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8P lanning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_PlanningServer_IBMCognos 8Planning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8P lanning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_PlanningServer_IBMCognos8 Planning84_post

:StartedService_PlanningServer_IBMCognos 8Planning84

REM Show final status before moving on to the next service/server
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

REM This section is left in strictly as a fail safe in case the IBM Cognos 8 service does not automatically
REM start with the start of the IBM Cognos 8 Planning 8.4 service. Generally speaking, this should only
REM serve to present the status of the IBM Cognos 8 service as running.

echo Status of IBM Cognos 8 service on PlanningServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on PlanningServer

:Resolve_START_PlanningServer_IBMCognos8 _pre
REM This is to check the status of this particular service prior to making any changes
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_PlanningServer_IBMCognos 8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_PlanningServer_IBMCognos8 _pre

:StartService_PlanningServer_IBMCognos8
echo start IBM Cognos 8 Service on EP App Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\PlanningServer start "IBM Cognos 8"

:Resolve_START_PlanningServer_IBMCognos8 _post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_PlanningServer_IBMCognos 8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_PlanningServer_IBMCognos8 _post

:StartedService_PlanningServer_IBMCognos 8

REM Show final status before moving on to the next service/server
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on GatewayServer

:Resolve_START_GatewayServer_IBMCognos8P lanning84_pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8Pl anning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_IBMCognos8 Planning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8Pl anning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_IBMCognos8P lanning84_pre

:StartService_GatewayServer_IBMCognos8Pl anning84
echo start IBM Cognos 8 Planning 8.4 and IBM Cognos 8 Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer start "IBM Cognos 8 Planning 8.4"

:Resolve_START_GatewayServer_IBMCognos8P lanning84_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8Pl anning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_IBMCognos8 Planning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8Pl anning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_IBMCognos8P lanning84_post

:StartedService_GatewayServer_IBMCognos8 Planning84

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"




Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

REM This section is left in strictly as a fail safe in case the IBM Cognos 8 service does not automatically
REM start with the start of the IBM Cognos 8 Planning 8.4 service. Generally speaking, this should only
REM serve to present the status of the IBM Cognos 8 service as running.

echo Status of IBM Cognos 8 service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on GatewayServer

:Resolve_START_GatewayServer_IBMCognos8_ pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_IBMCognos8_ pre

:StartService_GatewayServer_IBMCognos8
echo start IBM Cognos 8 Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer start "IBM Cognos 8"

:Resolve_START_GatewayServer_IBMCognos8_ post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_IBMCognos8_ post

:StartedService_GatewayServer_IBMCognos8

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"




Echo Cognos Services started %date% %time% >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"






Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

REM Delay, primarily for development and testing purposes to quickly review the environment
echo wait 15 seconds >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sleep 15

Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo completed RecycleServices_QA.bat >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo completed RecycleServices_QA.bat

echo wait 15 seconds
sleep 15

Echo --- >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo --- >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo --- >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Discussion

No Comment Found