VMware.View.Service.Start.Action (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.CommandOutput

Member Modules:

ID Module Type TypeId RunAs 
StartService WriteAction Microsoft.Windows.ScriptWriteAction Default

Source Code:

<WriteActionModuleType ID="VMware.View.Service.Start.Action" Accessibility="Internal">
<Configuration>
<xsd:element name="ServiceName" type="xsd:string"/>
</Configuration>
<ModuleImplementation>
<Composite>
<MemberModules>
<WriteAction ID="StartService" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>VMware.View.Service.Start.Action.vbs</ScriptName>
<Arguments>$Config/ServiceName$</Arguments>
<ScriptBody><Script>

' *
' * VMware.View.Service.Start.Action.vbs
' *
' * Starts a service.
' *


Option Explicit


WScript.Echo "Info: Initializing..."


Dim oArgs
Set oArgs = WScript.Arguments
If oArgs.Count &lt;&gt; 1 Then
On Error Goto 0
Err.Raise 8, _
"VMware.View.Service.Start.Action.vbs", _
"Wrong number of arguments"
End If


Dim ServiceName
ServiceName = oArgs(0)


Dim oWmi
Set oWmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
If oWmi Is Nothing Then
On Error Goto 0
Err.Raise 10, _
"VMware.View.Service.Start.Action.vbs", _
"Unable to open WMI provider: winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2"
End If


Dim oServiceSet
Set oServiceSet = oWmi.ExecQuery("Select * from Win32_Service Where Name='" &amp; ServiceName &amp; "'")
If oServiceSet Is Nothing Or oServiceSet.Count &lt; 1 Then
On Error Goto 0
Err.Raise 11, _
"VMware.View.Service.Start.Action.vbs", _
"Unable to find " &amp; ServiceName &amp; " service"
End If


WScript.Echo "Info: Starting " &amp; ServiceName &amp; " service..."


Dim oService
For Each oService in oServiceSet
oService.StartService
Next


WScript.Echo "Info: Started " &amp; ServiceName &amp; " service"


WScript.Quit(0)

</Script></ScriptBody>
<TimeoutSeconds>120</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="StartService"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.CommandOutput</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>