EN
Il contenuto non è disponibile nella lingua di destinazione, ma solo in inglese.

IShellDispatch2.ServiceStop method

Stops a named service.

Syntax


retVal = IShellDispatch2.ServiceStop(
  sServiceName,
  vPersistent
)

Parameters

sServiceName [in]

Type: BSTR

A String that contains the name of the service.

vPersistent [in]

Type: Variant

Set to true to have the service started by the service control manager when ServiceStart is called. To leave the service configuration unchanged, set vPersistent to false.

Return value

JScript

Type: Variant*

Returns true if successful; otherwise, false.

VB

Type: Variant*

Returns true if successful; otherwise, false.

Remarks

This method is implemented and accessed through the Shell.ServiceStop method.

The method returns false if the service has already been stopped. Before calling this method, you can call Shell.IsServiceRunning to ascertain the status of the service.

This method is not currently available in Microsoft Visual Basic.

Examples

The following examples show the use of ServiceStop to stop the Messenger service. Usage is shown for JScript and VBScript.

JScript:


<script language="JScript">
    function fnServiceStopJ()
    {
        var objShell = new ActiveXObject("shell.application");
        var bReturn;
        
        bReturn = objShell.ServiceStop("Messenger", true);
    }
</script>


VBScript:


<script language="VBScript">
    function fnServiceStopVB()
        dim objShell
        dim bReturn

        set objShell = CreateObject("shell.application")

        bReturn = objShell.ServiceStop("Messenger", true)

        set objShell = nothing
    end function
</script>


Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Shldisp.h

IDL

Shldisp.idl

DLL

Shell32.dll (version 5.0 or later)

 

 

Aggiunte alla community

AGGIUNGI
Mostra:
© 2014 Microsoft