Starts a named service.
Syntax
bSuccess = IShellDispatch2.ServiceStart(sServiceName, vPersistent)
Parameters
| sServiceName |
Required.
A String that contains the name of the service. |
| vPersistent |
Required.
A Variant value that is set to true to have the service started automatically by the service control manager during system startup. To leave the service configuration unchanged, set vPersistent to false. |
Return Value
Variant. Returns true if successful, or false otherwise.
Remarks
The method returns false if the service has already been started. Before calling this method, you can call IsServiceRunning to ascertain the status of the service.
This method is not currently available in Microsoft Visual Basic.
Examples
The following example uses
ServiceStart to start the Messenger service. Proper usage is shown for Microsoft JScript and Visual Basic Scripting Edition (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>
Applies To