Shell.ControlPanelItem method

Runs the specified Control Panel (*.cpl) application. If the application is already open, it will activate the running instance.

Note

As of Windows Vista, most Control Panel applications are Shell items and cannot be opened with this function. To open those Control Panel applications, pass the canonical name to control.exe. For example:

control.exe /name Microsoft.Personalization

 

Syntax

Shell.ControlPanelItem(
  bstrDir
)

Shell.ControlPanelItem( _
  ByVal bstrDir As BSTR _
)

Parameters

bstrDir [in]

Type: BSTR

The Control Panel application's file name. All Control Panel applications have the .cpl extension.

Return value

JScript

This method does not return a value.

VB

This method does not return a value.

Examples

The following example uses ControlPanelItem to run the Control Panel's Display Properties item. Proper usage is shown for JScript, VBScript, and Visual Basic.

JScript:

<script language="JScript">
    function fnShellControlPanelItemJ()
    {
        var objShell = new ActiveXObject("shell.application");
        
        objShell.ControlPanelItem("desk.cpl");
    }
</script>

VBScript:

<script language="VBScript">
    function fnShellControlPanelItemVB()
        dim objShell
        
        set objShell = CreateObject("shell.application")
        objShell.ControlPanelItem("desk.cpl")
       
        set objShell = nothing
    end function
 </script>

Visual Basic:

Private Sub fnShellControlPanelItemVB()
    Dim objShell As Shell
    
    Set objShell = New Shell
    objShell.ControlPanelItem ("desk.cpl")
    
    Set objShell = Nothing
End Sub

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Shldisp.h
IDL
Shldisp.idl
DLL
Shell32.dll (version 4.71 or later)