Clicky

Hi Experts

I am using Windows XP Pro SP3.

I was recently given the following suggestion by expert johnb6767 (http://www.qa.downappz.com/M_1197338.html):

Enumerate the list of installed Hotfixes using WMI
http://windowsxp.mvps.org/qfe.htm

wmic qfe list full /format:htable >C:\hotfixes.htm

When I try to change that to CSV output format:
wmic qfe list full /format:csv >C:\hotfixes.csv
the comma-separated file
 
hotfixes.csv (53 KB)
Output from WMIC command above (text/plain)

opens in Microsoft Excel (2003) with all the content in Column A.
Manually double-quoting the field names and field values between the delimiters doesn't change the way it opens in Excel.  I do notice that it has a blank first line, but even removing that doesn't change how it opens in Excel.

Any other *.CSV file that I have created (eg. manually, from batch files, downloaded bank statements, etc) open fine in Excel, with only those values containing spaces being double-quoted, so I am puzzled why the WMIC output doesn't open in the same way.

The formatting is apparently done by "C:\WINDOWS\system32\wbem\csv.xsl" (attached as text file):
 
csv-xsl.txt (2 KB)
Windows XP SP3 "csv.xsl" file (text/xml)

but I can't see where I would be able to modify it if it is adding some other symbol instead of a standard ascii comma, or how I can eliminate the blank first line.  The intention would be to create a copy of the XSL file as, eg. "CSV2.xsl" and call that with the path instead:
wmic qfe list full /format:"C:\WINDOWS\system32\wbem\csv2.xsl">C:\hotfixes.csv

Any ideas, or is it something wonky with my system?

Thanks
Bill

asked 06/26/2011 04:23

BillDL's gravatar image

BillDL ♦♦


3 Answers:
BillDL,

The file is in UniCode. Given that format, two options are...
(A) Change file-type to ".txt" rather than ".csv". The Text Import Wizard runs when you open the file - just use "Delimeited" and select "Comma" on the second screen.

(B) Use the DOS "Type" command to convert the file, e.g. "Type C:hotfixes.csv > C:hotfixes_II.csv".

Alternatively, you could bypass the problem completely by replacing the "WMIC" command by...
 
1:
wmic qfe list full /format:csv | find "not goNna be here" /v > C:hotfixes.csv

Regards,
Brian.
link
redmondb's gravatar image

redmondb

Thank you Brian.  I hadn't considered the Unicode aspect.  I would use the last one that pipes it through the Find command.  Excellent.
link
BillDL's gravatar image

BillDL

Thanks, BillDL.
link
redmondb's gravatar image

redmondb

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×1
×1
×3
×1

Asked: 06/26/2011 04:23

Seen: 13905 times

Last updated: 06/26/2011 02:18