Starting, stopping and pauseing a service. 
Author Message
 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



Mon, 26 Apr 2004 09:06:42 GMT  
 Starting, stopping and pauseing a service.
... Getobject("WinNT://" & strComputer ...

The WinNT: COM moniker for the WinNT ADSI provider is case sensitive.

--
Michael Harris
Microsoft.MVP.Scripting

Quote:

> 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



Mon, 26 Apr 2004 11:30:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problems with stopping/starting service

2. How to start/stop services with vbscript?

3. START/STOP/ displayed Services running on PC thu an ASP page

4. How to start/stop a NT service

5. start and stop services

6. login script to start/stop service

7. stop/start a service in VBS

8. Stop and Starting Services on NT

9. Starting and Stopping NT Services with ADSI,wsh, and VBScript

10. Start/Stop a NT Service using wsh/adsi

11. Starting and stopping Services from ASP or VBS

12. Service Stop/Start

 

 
Powered by phpBB® Forum Software