
Starting, stopping and pauseing a service.
Hi,
Can someone enlighten me on and ADSI issue.
If you are trying to stop a service on an NT Server using VBScript & ADSI,
do you have to specify in the VBScript that you are logging into the server?
I have some code below and I keep getting an error message on line
(GetObject) even though I have specified the user and password to login to
the server.
Dim strComputer
Dim strService
Dim strUser
Dim strPassword
On Error Resume Next
strComputer = "SV10DBDEV"
strService = "MSSQLServer"
strUser = "Administrator"
strPassword = ""
Set oService = Getobject("Winnt://" & strComputer & "/" & strService &
",Service")
If (Err.Number <> 0) Then
Wscript.Echo(Err.Description&" "&Err.Number)
Wscript.Quit
End If
If oService.Status = ADS_SERVICE_STOPPED Then
MsgBox "SQL Service is not running", vbCritical, "SQL Service Check"
WScript.Echo "Service Display Name = " & oService.DisplayName
WScript.Echo "Service Account Name = " & oService.ServiceAccountName
WScript.Echo "Service Executable = " & oService.Path
Else
MsgBox "SQL Service running", vbOKOnly, "SQL Service Check"
End If
''''Clean Up''''
Set strComputer = Nothing
Set strService = Nothing
Set strUser = Nothing
Set strPassword = Nothing