Shell.IsServiceRunning method

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

Syntax

retVal = Shell.IsServiceRunning(
  sServiceName
)

Shell.IsServiceRunning( _
  ByVal sServiceName As BSTR _
) As Variant

Parameters

sServiceName [in]

Type: BSTR

A String that contains the name of the service.

Return value

JScript

Type: Variant*

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

VB

Type: Variant*

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

Remarks

This method is not currently available in Microsoft Visual Basic.

Examples

The following examples show the use of IsServiceRunning to determine whether the Themes service is running for an application. Usage is shown for JScript and 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

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)