List of installed programs
2010-12-10 perl wmic one-linerThis shows how to get list of installed programs on Windows machines.
Thanks to this blog entry (and one comment below) I learned about existence of nice tool shipped by default with Windows installation - wmic (Windows Management Instrumentation Command).
It can gather various types of information from your workstation, like example below. Running this from command-line get you list of all installed programs with their version, separated by tab.
wmic product list /format:csv.xsl | perl -F, -lanE "say qq{$F[1]\t$F[10]}"
Part by part. wmic product list /format:csv.xsl
returns list of programs
installed, formatted with csv.xsl
XSLT template. Output is like this:
Node,Description,IdentifyingNumber,InstallDate,....
BVR,Mobipocket Reader 6.2,{342126E1-173C-4585-.....
The columns are:
[ 0] Node
[ 1] Description
[ 2] IdentifyingNumber
[ 3] InstallDate
[ 4] InstallLocation
[ 5] InstallState
[ 6] Name
[ 7] PackageCache
[ 8] SKUNumber
[ 9] Vendor
[10] Version
So next part is running perl one-liner, processing this csv. Since there is
not much escaping we can safely split line on comma (-F,
switch), process
each line with code specified on command-line (-nE
switch) with automatic
removing of trailing newlines (-la
switch).
The code is just printing column 1 with description and column 10 with version
separated by tab. Note that Windows does not support single quoting, so I had
to use qq
synonym to quotes in perl code.