Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windows Shell
Shell Reference
IShellDispatch2
Methods
 ServiceStop Method
ServiceStop Method

Stops a named service.

Syntax

bSuccess = IShellDispatch2.ServiceStop(sServiceName, vPersistent)

Parameters

sServiceName Required. A String that contains the name of the service.
vPersistent Required. A Variant that is 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

Variant. Returns true if successful, or false otherwise.

Remarks

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

This method is not currently available in Microsoft Visual Basic.

Examples

The following example uses ServiceStop to stop the Messenger service. Proper usage is shown for Microsoft JScript and Visual Basic Scripting Edition (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>

Applies To

IShellDispatch2
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker