Discovered Issue and Fix for Inventory Solution x64 Add Remove Programs Data Workaround
Anyone familiar with Inventory Solution for Windows and 64-bit operating systems should know that Inventory Solution 6.1 SP2 does not pull 64-bit programs into the Inv AeX OS Add Remove Programs table. Altiris has published a workaround for this in AKB 39284.
However, this workaround does not account for any program names with apostrophe's in their names which causes the generated XML to be faulty and not import correctly. In our environment, this information is bundled in the same NSE as a majority of our data from the Software Inventory task, so any system with an apostrophe in its program name causes us to never receive any updates to that table or the Inv AeX SW Audit Software table. Any tasks (targeted software delivery jobs or otherwise) that are dependent on either of these two tables for software installs/uninstalls may yield undesirable results.
When doing some troubleshooting, I ran across this in the NS's log:
Log File Name: F:\Program Files\Altiris\Notification Server\Logs\a.log Priority: 1 Date: 5/21/2009 7:24:42 AM Tick Count: 494592421 Host Name: NSSERVER Process: aexsvc.exe (1388) Thread ID: 5448 Module: AltirisNativeHelper.dll Source: Altiris.NS.ClientMessaging.FileDispatcher.ProcessFileCallback Description: Unable to process the file "F:\Program Files\Altiris\Notification Server\NSCap\EvtQueue\Process\nseF213.tmp" Moving to "F:\Program Files\Altiris\Notification Server\NSCap\EvtQueue\Bad\XmlException\nseF215.tmp". Reason: This is an unexpected token. The expected token is 'NAME'. Line 454, position 46.
When I pulled up the offending file and went to line 454, I was presented with the following (note: I tweaked the registry on the test box to include an apostrophe in the program name and the path name.)
<row c0='Testing Random Software With David's Apostrophe Issue' c1='False' c2='5.2' c3='' c4='C:\Program Files\Apostrophe's\uninstall.exe' c5='' c6='' c7='' c8='' c9='' c10='' />
Position 46 is just after the apostrophe. Since the tags are being opened/closed by apostrophes instead of double-quotes, the XML thinks that c0 stops at the word David, and the extra apostrophe throws the rest of the file off.
Elsewhere in that same file I noticed the " tag was being used to generate double quotes without interfering with the XML. The same must hold true for apostrophes, right? Yes. The ' tag will allow the XML to go through with zero problems.
If you dig into the AddRemoveProgramsX64.vbs file referenced in the KB article, at the bottom you'll see a function ToXmlString which is what we're going to need to change for this fix. After seeing the logic behind the other string replacements, I added the boldfaced line replacing the apostrophe (Chr(39)) with ' and everything was fine after that.
Function ToXmlString (strInput) Dim strOutput If (IsNull(strInput)) Then ToXMLString = strInput Else strOutput = Replace(strInput, "&", "&") strOutput = Replace(strOutput, """", """) strOutput = Replace(strOutput, Chr(39), "'") strOutput = Replace(strOutput, "<", "<") ToXmlString = Replace(strOutput, ">", ">") End If End Function
I've heard this issue was supposed to be fixed in Inventory Solution 6.1 SP3 when it is released, but if you have a larger environment you may not be able to upgrade right away without doing some testing, so I wanted to throw out this fix for anyone else that may be suffering from this issue in the meantime.