Get Application Version using Python

In software development, whenever developers add new features or fix bugs in an application, they assign it a new version number. This helps users identify the latest updates and features available in that application.

Using Python, we can retrieve the version of any application installed on Windows systems. We'll use the pywin32 library to interact with executable files through the Win32 API, which provides access to Windows system information.

Installation

First, install the required package ?

pip install pywin32

Getting Application Version

Here's how to retrieve the version number of any Windows application ?

from win32com.client import Dispatch

def get_version_number(app_location):
    """Get version number of an application"""
    parser = Dispatch("Scripting.FileSystemObject")
    version = parser.GetFileVersion(app_location)
    return version

# Example: Get Chrome version
app_location = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
version = get_version_number(app_location)
print(f"Chrome version: {version}")

The output will be ?

Chrome version: 89.0.4389.114

How It Works

The process involves these key steps:

  • Dispatch("Scripting.FileSystemObject") − Creates a COM object to interact with the file system

  • GetFileVersion() − Extracts version information from the executable file's metadata

  • File path − Must point to the actual executable (.exe) file

Examples with Different Applications

You can get version information for various applications ?

from win32com.client import Dispatch

def get_version_number(app_location):
    try:
        parser = Dispatch("Scripting.FileSystemObject")
        version = parser.GetFileVersion(app_location)
        return version
    except Exception as e:
        return f"Error: {str(e)}"

# Different application paths
applications = {
    'Chrome': r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe',
    'Firefox': r'C:\Program Files\Mozilla Firefox\firefox.exe',
    'Notepad++': r'C:\Program Files\Notepad++\notepad++.exe',
    'VLC': r'C:\Program Files\VideoLAN\VLC\vlc.exe'
}

for app_name, path in applications.items():
    version = get_version_number(path)
    print(f"{app_name}: {version}")

Error Handling

The improved version includes error handling for cases where the application might not be installed or the path is incorrect ?

import os
from win32com.client import Dispatch

def get_app_version(app_path):
    if not os.path.exists(app_path):
        return "Application not found"
    
    try:
        parser = Dispatch("Scripting.FileSystemObject")
        version = parser.GetFileVersion(app_path)
        return version if version else "Version not available"
    except Exception as e:
        return f"Error reading version: {str(e)}"

# Test with error handling
app_path = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
result = get_app_version(app_path)
print(f"Result: {result}")

Conclusion

The pywin32 library provides an efficient way to retrieve application version information on Windows systems. Always include error handling and verify file paths exist before attempting to read version data.

Updated on: 2026-03-25T19:27:23+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements