joseomjr
Tue Jan 30 18:09:00 CST 2007
A popular method is using CDO for emailing. This link has several
examples. You should be able to put one into a Sub and then call it
after you start the service.
http://www.paulsadowski.com/WSH/cdo.htm
On Jan 30, 7:17 am, johnisccp <johnis...@discussions.microsoft.com>
wrote:
> Thanks that work fine. Is there a way for me to include a line that would
> email me when the service is started?
>
> "joseo...@gmail.com" wrote:
> > Try something like this:
>
> > strComputer = "."
> > Set objShell = CreateObject("WScript.Shell")
> > Set objWMIService = GetObject(_
> > "winmgmts:\\" & strComputer & "\root\cimv2")
> > Set colPings = objWMIService.ExecQuery _
> > ("Select * From Win32_PingStatus where Address = '137.1.3.85'")
> > For Each objStatus in colPings
> > If IsNull(objStatus.StatusCode) _
> > or objStatus.StatusCode<>0 Then
> > WScript.Echo "Computer did not respond."
> > objShell.Run "sc start WZCSVC"
> > Else
> > Wscript.Echo "Computer responded."
> > End If
> > Next
>
> > On Jan 29, 10:10 am, johnisccp <johnis...@discussions.microsoft.com>
> > wrote:
> > > I am using the ping status WMI script that check if a remote server is up or
> > > not. I have the ping status working but I would like to run "sc start
> > > WZCSVC" on the local server or some way to start a service after the remote
> > > server do not respond. Here is the code:
>
> > > strComputer = "."
> > > Set objWMIService = GetObject(_
> > > "winmgmts:\\" & strComputer & "\root\cimv2")
> > > Set colPings = objWMIService.ExecQuery _
> > > ("Select * From Win32_PingStatus where Address = '137.1.3.85'")
> > > For Each objStatus in colPings
> > > If IsNull(objStatus.StatusCode) _
> > > or objStatus.StatusCode<>0 Then
> > > WScript.Echo "Computer did not respond."
> > > do "sc start WZCSVC"
> > > Else
> > > Wscript.Echo "Computer responded."
> > > End If
> > > Next