IShellDispatch2.IsServiceRunning method

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

Syntax

retVal = IShellDispatch2.IsServiceRunning(
  sServiceName
)

IShellDispatch2.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 implemented and accessed through the Shell.IsServiceRunning method.

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:

<script language="JScript">
    function fnIsServiceRunningJ()
    {
        var objShell = new ActiveXObject("shell.application");
        var bReturn;
    
        bReturn = objShell.IsServiceRunning("Themes");
    }
</script>

VBScript:

<script language="VBScript">
    function fnIsServiceRunningVB()
        dim objShell
        dim bReturn
    
        set objShell = CreateObject("shell.application")
    
        bReturn = objShell.IsServiceRunning("Themes")
    
        set objShell = nothing
    end function
</script>

Requirements

Requirement Value
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)