File: C:/Windows/OEM/GuestInterface.wsf
<package>
<?component error="true" debug="true" ?>
<comment>
Abstracts PA functionality for XIO support
</comment>
<component id="GuestInterface">
<registration
progid="WaGuest.GuestInterface"
description=""
version="1.0.0.0"
clsid="{BC8C7B6C-EC7E-B027-D1B7-6874FA6D3B6C}"/>
<public>
<property name="WScript" />
<property name="WireServerAddress" />
<method name="Initialize" />
<method name="PutProvisioningStatus">
<param name="status" />
<param name="substatus" />
<param name="description" />
<param name="properties" />
</method>
<method name="GetCertificates" />
<method name="SendTelemetry">
<param name="operation" />
<param name="message" />
<param name="durationMS" />
</method>
</public>
<resource id="1"></resource>
<object id="FSO" progid="Scripting.FileSystemObject" />
<object id="WshShell" progid="WScript.Shell" />
<script language="VBScript" src="Utility.vbs" />
<script language="VBScript">
Const ERROR_DISCOVERYFAILURE = 2
Const INITIAL_GOAL_STATE_RETRY_MINS = 20
Dim g_Trace, oTraceEvent
Dim g_ProtocolImpl
Sub Initialize()
Set g_Trace = GetScriptObject(Me.WScript, "Tracing.wsf", "TraceSource")
g_Trace.Name = "GuestInterface"
InitializeWireServerClient()
If TraceError (g_Trace, "Initialize: InitializeWireServerClient failed") <> 0 Then
TraceError g_Trace, "Initialize: LogNetworkingData failed"
End If
End Sub
Private Sub InitializeWireServerClient()
Dim wireServerAddress
On Error Resume Next
Set g_ProtocolImpl = GetScriptObject(Me.WScript, "WireServer.wsf", "WireServer")
Set g_ProtocolImpl.WScript = Me.WScript
g_ProtocolImpl.Initialize
If TraceErrorWithoutClear(g_Trace, "InitializeWireServerClient: WireServer initialization failed with ErrNo " & CStr(Err.Number) & ". No server is available") <> 0 Then
Exit Sub
End If
wireServerAddress = g_ProtocolImpl.ServerAddress
Me.WireServerAddress = wireServerAddress
If Not IsNull(wireServerAddress) Then
' initialize GoalState
Dim m_objGoalState
Me.WScript.Echo "Initializing Goal State"
Set m_objGoalState = g_ProtocolImpl.GetGoalState(INITIAL_GOAL_STATE_RETRY_MINS * 60)
If TraceErrorWithoutClear(g_Trace, "InitializeWireServerClient: g_ProtocolImpl.GetGoalState failed with ErrNo " & CStr(Err.Number)) <> 0 Then
Exit Sub
End If
If Not(m_objGoalState.MachineExpectedState = "Started") Then
' the goal state says that the VM should stop, so avoid reporting any progress on that.
' it is tantamount to the wire protocol being unavailable.
Set m_objGoalState = Nothing
Exit Sub
End If
Set oTraceEvent = g_Trace.CreateEvent("INFO")
With oTraceEvent.appendChild(oTraceEvent.ownerDocument.createElement("GoalState"))
.setAttribute "MachineExpectedState", m_objGoalState.MachineExpectedState
End With
g_Trace.TraceEvent oTraceEvent
Else
Err.Raise vbObjectError + ERROR_NOTINITALIZED, "GuestInterface.wsf", "Failed to discover wireserver"
End If
End Sub
Sub PutProvisioningStatus(status, substatus, description, properties)
g_ProtocolImpl.PutProvisioningStatus status, substatus, description, properties
End Sub
Sub SendTelemetry(operation, message, durationMS)
g_ProtocolImpl.SendTelemetry operation, message, durationMS
End Sub
Function GetCertificates()
GetCertificates = g_ProtocolImpl.GetCertificates()
End Function
</script>
</component>
</package>