description | ms.assetid | title | ms.topic | ms.date | topic_type | api_name | api_type | api_location | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
IShellDispatch2.ServiceStart method - Starts a named service. |
3af57cdc-f449-433d-a9e1-119038045e4c |
IShellDispatch2.ServiceStart method (Shldisp.h) |
reference |
05/31/2018 |
|
|
|
|
Starts a named service.
retVal = IShellDispatch2.ServiceStart(
sServiceName,
vPersistent
)
IShellDispatch2.ServiceStart( _
ByVal sServiceName As BSTR, _
ByVal vPersistent As Variant _
) As Variant
-
sServiceName [in]
-
Type: BSTR
A String that contains the name of the service.
-
vPersistent [in]
-
Type: Variant
Set to true to have the service started automatically by the service control manager during system startup. Set to false to leave the service configuration unchanged.
Type: Variant*
Returns true if successful; otherwise, false.
Type: Variant*
Returns true if successful; otherwise, false.
This method is implemented and accessed through the Shell.ServiceStart method.
The method returns false if the service has already been started. Before calling this method, you can call Shell.IsServiceRunning to ascertain the status of the service.
This method is not currently available in Microsoft Visual Basic.
The following examples show the use of ServiceStart to start the Messenger service. Usage is shown for JScript and VBScript.
JScript:
<script language="JScript">
function fnServiceStartJ()
{
var objShell = new ActiveXObject("shell.application");
var bReturn;
bReturn = objShell.ServiceStart("Messenger", true);
}
</script>
VBScript:
<script language="VBScript">
function fnServiceStartVB()
dim objShell
dim bReturn
set objShell = CreateObject("shell.application")
bReturn = objShell.ServiceStart("Messenger", true)
set objShell = nothing
end function
</script>
Requirement | Value |
---|---|
Minimum supported client |
Windows 2000 Professional, Windows XP [desktop apps only] |
Minimum supported server |
Windows Server 2003 [desktop apps only] |
Header |
|
IDL |
|
DLL |
|