IsServiceRunning Method

Returns a value that indicates whether a named service is running.

Syntax

bIsRunning = IShellDispatch2.IsServiceRunning(sServiceName)

Parameters

sServiceName Required. A String that contains the service's name.

Return Value

Variant. Returns true if the service specified by sServiceName is running, or false otherwise.

Remarks

This method is not currently available in Microsoft Visual Basic.

Examples

The following example uses IsServiceRunning to determine whether the Themes service is running for a particular application. Proper usage is shown for Microsoft JScript and Visual Basic Scripting Edition (VBScript).

JScript:

function fnIsServiceRunningJ()
{
    var objShell = new ActiveXObject("Shell.Application");
    var bReturn;

    bReturn = objShell.IsServiceRunning("Themes");
}

VBScript:

function fnIsServiceRunningVB()
    dim objShell
    dim bReturn

    set objShell = CreateObject("Shell.Application")
         bReturn = objShell.IsServiceRunning("Themes")
    set objShell = nothing
end function

Applies To

IShellDispatch2
Tags :


Page view tracker