Not sure if you're thinking about it, but if you are planning to use a VBS
script to manage the shutdown, you might want to add logging, or even e-mail
alerting (see below). I modified this slightly from another example in the
script library Rick mentions below. You could possibly use it to send
e-mail alerts when you start/stop services from a host that doesn't have the
SMTP service installed.
Richard
option explicit
dim strSender, strRecip, strSubj, strBody, strSrv
on error resume next
strSender = "[EMAIL PROTECTED]"
strRecip = "[EMAIL PROTECTED]"
strSubj = "a managed shutdown of SQL Services occurred at " _
& time & " on " & date
strBody = "backups are currently in progress"
strSrv = "smtpserver.mycompany.com"
call e_mail(strSender, _
strRecip, _
strSubj, _
strBody, _
strSrv)
sub e_mail(Sender, Recipient, SubjectLine, _
MessageBody, SMTPServer)
dim objEmail
Set objEmail = CreateObject("CDO.Message")
objEmail.From = Sender
objEmail.To = Recipient
objEmail.Subject = SubjectLine
objEmail.Textbody = MessageBody
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Set objEmail = Nothing
end sub
-----Original Message-----
From: Jones, Rick J.(Desktop Engineering) [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 11, 2002 1:02 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [ActiveDir] OT: How to schedule a service to stop and restar t?
>From the system administration Script Guide Script Repository
(http://www.microsoft.com/downloads/release.asp?ReleaseID=38942)
Stop a Service and Its Dependents
Description
Stops the NetDDE service and all its dependent services.
Script Code
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery("Associators of " _
& "{Win32_Service.Name='NetDDE'} Where " _
& "AssocClass=Win32_DependentService " & "Role=Antecedent" )
For each objService in colServiceList
objService.StopService()
Next
Wscript.Sleep 20000
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='NetDDE'")
For each objService in colServiceList
errReturn = objService.StopService()
Next
Start a Service and Its Dependents
Description
Starts the NetDDE service and all its dependent services.
Script Code
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='NetDDE'")
For each objService in colServiceList
errReturn = objService.StartService()
Next
Wscript.Sleep 20000
Set colServiceList = objWMIService.ExecQuery("Associators of " _
& "{Win32_Service.Name='NetDDE'} Where " _
& "AssocClass=Win32_DependentService " & "Role=Dependent" )
For each objService in colServiceList
objService.StartService()
Next
You should be able to adjust this for your specific service and make 2
scripts that you could put into your scheduled tasks, 1 for shut down, the
other for start up.
Rick J. Jones
-----Original Message-----
From: Kevin Felker [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 11, 2002 9:47 AM
To: [EMAIL PROTECTED]
Subject: [ActiveDir] OT: How to schedule a service to stop and restart?
All,
I'm trying to do a system backup of my server, but not all of it is
backing up since certain services are running (such as SQL SERVER).
If I have my backup scheduled for 3:00AM, I would like to stop the SQL
SERVER Service at 2:50AM, and restart it at 4:00AM.
What is the best way to do this?
Thanks
Kevin
List info : http://www.activedir.org/mail_list.htm
List FAQ : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
List info : http://www.activedir.org/mail_list.htm
List FAQ : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/