programming

List Installed Programs on Windows

You can get a list of all the available software installed on your Windows System. The below Power Shell script will put all the info into a file and in table view so that you can print it out.

You can get this infomoration several ways:

  • PowerShell - appears to be most detailed
  • CMD via wmic - gives a very basic report
  • Python - more to come

PowerShell

  1. Go to start menu and search for Power Shell -> right-click and open as ADMIN
  2. The copy/past the below scrip and make any needed changes
  3. You txt file will end-up at the root of drive C:\ unless you changed the destination
  4. Code Below will be in table format and the returning information may be truncated to 15 charactors
[code]Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize > C:\InstalledProgramsPS_todaysdate.txt[/code]
  1. The below code will give you a list op programs in data format. This will return all fields in full view
  2. you should notice the | Format-Table - AutoSize has been removed
[code]Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate, InstallLocation, URLUpdateInfo > C:\InstalledProgramsPS_01102019_1433.txt[/code]
  •  Listed below are most of the Window's 7 fields you can get information on.
[code]AssignmentType,Caption, Description,HelpLink,HelpTelephone,IdentifyingNumber,InstallDate,InstallDate2,InstallLocation,InstallSource,InstallState, Language, LocalPackage, Name,PackageCache, PackageCode,PackageName, ProductID, RegCompany, RegOwner, SKUNumber, Transforms, URLInfoAbout, URLUpdateInfo, Vendor,Version, WordCount,[/code]

 

 CMD - wmic

  1. Open your start meny and search CMD -> open as admin
  2. In the command window type wmic - this start the wmic prompt
  3. copy/paste the below code - modify as needed to fit your system.

 

[code]/output:C:\InstalledProgramsWMIC_CurrentDateHere.txt product get name,version[/code]

 


Python

  1. This is based on Python v2 and not tested on every system
[code]## Python Version 2

# This scripts allows to get a list of all installed products in a windows

# machine. The code uses ctypes becuase there were a number of issues when

# trying to achieve the same win win32com.client

# Code from this publisher (Thanks) - https://ashishpython.blogspot.com/2013/12/listing-all-installed-applications-on.html

from collections import namedtuple

from ctypes import byref, create_unicode_buffer, windll

from ctypes.wintypes import DWORD

from itertools import count

 

# defined at http://msdn.microsoft.com/en-us/library/aa370101(v=VS.85).aspx

UID_BUFFER_SIZE = 39

PROPERTY_BUFFER_SIZE = 256 

ERROR_MORE_DATA = 234

ERROR_INVALID_PARAMETER = 87

ERROR_SUCCESS = 0

ERROR_NO_MORE_ITEMS = 259 

ERROR_UNKNOWN_PRODUCT = 1605 

 

# diff propoerties of a product, not all products have all properties

PRODUCT_PROPERTIES = [u'Language',

                      u'ProductName',

                      u'PackageCode',

                      u'Transforms',

                      u'AssignmentType',

                      u'PackageName',

                      u'InstalledProductName',

                      u'VersionString',

                      u'RegCompany',

                      u'RegOwner',

                      u'ProductID',

                      u'ProductIcon',

                      u'InstallLocation',

                      u'InstallSource',

                      u'InstallDate',

                      u'Publisher',

                      u'LocalPackage',

                      u'HelpLink',

                      u'HelpTelephone',

                      u'URLInfoAbout',

                      u'URLUpdateInfo',] 

 

# class to be used for python users :)

Product = namedtuple('Product', PRODUCT_PROPERTIES)

 

 

def get_property_for_product(product, property, buf_size=PROPERTY_BUFFER_SIZE):

    """Retruns the value of a fiven property from a product."""

    property_buffer = create_unicode_buffer(buf_size)

    size = DWORD(buf_size)

    result = windll.msi.MsiGetProductInfoW(product, property, property_buffer,

                                           byref(size))

    if result == ERROR_MORE_DATA:

        return get_property_for_product(product, property,

                2 * buf_size)

    elif result == ERROR_SUCCESS:

        return property_buffer.value

    else:

        return None

 

 

def populate_product(uid):

    """Return a Product with the different present data."""

    properties = []

    for property in PRODUCT_PROPERTIES:

        properties.append(get_property_for_product(uid, property))

    return Product(*properties) 

 

 

def get_installed_products_uids():

    """Returns a list with all the different uid of the installed apps."""

    # enum will return an error code according to the result of the app

    products = []

    for i in count(0):

        uid_buffer = create_unicode_buffer(UID_BUFFER_SIZE)

        result = windll.msi.MsiEnumProductsW(i, uid_buffer)

        if result == ERROR_NO_MORE_ITEMS:

            # done interating over the collection

            break

        products.append(uid_buffer.value)

    return products

 

 

def get_installed_products():

    """Returns a collection of products that are installed in the system."""

    products = []

    for puid in  get_installed_products_uids():

        products.append(populate_product(puid))

    return products 

 

 

def is_product_installed_uid(uid):

    """Return if a product with the given id is installed.

 

    uid Most be a unicode object with the uid of the product using

    the following format {uid}

    """

    # we try to get the VersisonString for the uid, if we get an error it means

    # that the product is not installed in the system.

    buf_size = 256

    uid_buffer = create_unicode_buffer(uid)

    property = u'VersionString'

    property_buffer = create_unicode_buffer(buf_size)

    size = DWORD(buf_size)

    result = windll.msi.MsiGetProductInfoW(uid_buffer, property, property_buffer,

                                           byref(size))

    if result == ERROR_UNKNOWN_PRODUCT:

        return False

    else:

        return True



apps=get_installed_products()

for app in apps:

    print app.InstalledProductName[/code]

You can get more information from here:

https://www.makeuseof.com/tag/list-installed-programs-windows/

Keywords: N/A