Link to home
Start Free TrialLog in
Avatar of orcun_turkec
orcun_turkecFlag for Türkiye

asked on

Windows batch script to check if Oracle Services have been stopped


Hi experts,

I' m using Oracle 11G on Windows 98.   I need a script to check  several  oracle services in windows.  I want to be informed if their status is " Stopped" .
I just need a  message variable to be set like ' Oracle Job Scheduler is not working ' when the status of the OracleJobSchedulerORCL  service ( my sid is ORCL )   is " Stopped ".
Then I' ll link them with an e-mail script.    

 
Avatar of gatorvip
gatorvip
Flag of United States of America image

>>I' m using Oracle 11G on Windows 98.  

Wow, that's not something you hear every day. Are you sure it's 98 and not something else, like Windows 2000+ (including 2008)?


If it's a more recent OS, then the following VBScript could work for you:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
	& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

' change/remove the StartMode if you don't need it
Set colListOfServices = objWMIService.ExecQuery _
	("Select * from Win32_Service Where State = 'Stopped' and StartMode = " _
		& "'Auto'")  

For Each objService in colListOfServices
	If objService.DisplayName="<the name of your Oracle service>" Then
		objService.StartService()
	End If
Next

Open in new window

Avatar of orcun_turkec

ASKER

Hi Gatorvip,

Thank you for the script,  I think at the row 12  with the command  ' objService.StartService()'  the service is restarted.   I don' t want to start the service but want to create variable like
service_message and the value of that variable like ' Oracle Service is not working in  computername'.
There are many servers and I will apply this script manually  so computername is important. How can I create that message  assigning a variable ?




 
ASKER CERTIFIED SOLUTION
Avatar of Krzysztof Pytko
Krzysztof Pytko
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you
You're welcome :)