Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VBS : "output is not an XML document" How to encode the displayed result, from a VBS, into a format UTF-8 ? (Microsoft.XMLDOM)

$
0
0
Question
Vous ne pouvez pas voter pour votre propre billet.

Hello,
I write some VBS files to display the informations that come from different versions of Windows.
+ Windows : XP, 2003, 2008 R2, 2012.
+ Informations : 
 # Displays protocol statistics and current TCP/IP network connections. (netstat -ano)
 # Versions of the EXE files
 # Installed patchs (Windows Updates and others)
 # Scheduled tasks (winschtask and at)
 # Local Windows users
 # Last logged user
--
For this activity, I use the tool OCS Inventory, to save the informations inside the SQL Database.
On each windows computer, I install a OCS Agent.
Using cscript <file>.vbs, all the resultats are good, no problem.
Using the OCS Agent, I discover some troubls, with error message : "output is not an XML document"

--
After long discussions withe OCS DEV Team, it appears that the displayed results are not well encoded.
It must be UTF-8.
The propose to me to use the methods "Microsoft.XMLDOM".
But I have sompe problems to understand these methods.
---
For example a VBS :
---

Dim objShell, objExec
Set objShell = CreateObject("WScript.Shell")

Set objExec = objShell.Exec("netstat -ano")

'Wait the end of the run of the command NETSTAT -anoDo While objExec.Status <> 0
    WScript.Sleep 10
Loop

'Read the result of the command, skip the first lines, and display the XML codeDo While objExec.StdOut.AtEndOfStream <> True
    strNetStatANO = objExec.StdOut.ReadLine
    If objExec.StdOut.Line > 5 Then
        Wscript.echo "   <NETSTATANO>"
        Wscript.echo "      <PROTOCOL>"        & Trim(Mid(strNetStatANO,3,7))   & "</PROTOCOL>"
        Wscript.echo "      <LOCAL_ADDRESS>"   & Trim(Mid(strNetStatANO,10,23)) & "</LOCAL_ADDRESS>"
        Wscript.echo "      <FOREIGN_ADDRESS>" & Trim(Mid(strNetStatANO,33,23)) & "</FOREIGN_ADDRESS>"
        Wscript.echo "      <STATE>"           & Trim(Mid(strNetStatANO,56,16)) & "</STATE>"
        Wscript.echo "      <PID>"             & Trim(Mid(strNetStatANO,72))    & "</PID>"
        Wscript.echo "   </NETSTATANO>"
    End If
Loop

---



Viewing all articles
Browse latest Browse all 15028

Trending Articles