Setup/Windows/Tracing.wsf (77 lines of code) (raw):
<?XML version="1.0" ?>
<package>
<?component error="true" debug="true" ?>
<comment>
</comment>
<component id="TraceSource">
<registration
progid="WaGuest.TraceSource"
description="description"
version="1.0.0.0"
clsid="{73E31C0A-9A21-43D2-B1F1-68C2E307A2B4}"/>
<public>
<property name="Name" />
<method name="CreateEvent" />
<method name="TraceEvent" />
</public>
<object id="FSO" progid="Scripting.FileSystemObject" />
<script language="VBScript"><![CDATA[
Option Explicit
Dim g_LogFilePath
g_LogFilePath = FSO.BuildPath(FSO.GetSpecialFolder(0), "Panther\ProxyAgentInstaller.xml")
Function HexJS(i)
HexJS = Hex(i)
End Function
Function CreateEvent(Category)
Dim evtDoc, evt
Set evtDoc = CreateObject( "Microsoft.XMLDOM" )
Set evt = evtDoc.createElement("Event")
With evtDoc.appendChild(evt)
.setAttribute "time", formatCurrentDate()
.setAttribute "category", Category
.setAttribute "source", Me.Name
End With
Set CreateEvent = evt
End Function
Sub TraceEvent(evt)
' write the event to the event log
Dim errorNumber
On Error Resume Next
Do
Dim oLogStream
Err.Clear
Set oLogStream = FSO.OpenTextFile(g_LogFilePath, 8, -1)
errorNumber = Err.number
If errorNumber = 0 Then
oLogStream.WriteLine evt.xml
End If
If Not (IsEmpty(oLogStream)) Then
oLogStream.Close
End If
Loop While errorNumber = &H46
End Sub
]]></script>
<script language="JScript"><![CDATA[
function formatCurrentDate() {
var d = new Date();
return "" +
d.getUTCFullYear() + "-" +
padDigits(d.getUTCMonth() + 1, 2) + "-" +
padDigits(d.getUTCDate(), 2) + "T" +
padDigits(d.getUTCHours(), 2) + ":" +
padDigits(d.getUTCMinutes(), 2) + ":" +
padDigits(d.getUTCSeconds(), 2) + "." +
padDigits(d.getUTCMilliseconds(), 3) + "Z";
}
function padDigits(n, totalDigits) {
n = n.toString();
var pd = "";
for (i = 0; i < (totalDigits - n.length); i++) {
pd += "0";
}
return pd + n;
}
]]>
</script>
</component>
</package>