Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: installed_.net_frameworks.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- This script retrieves version information about all installed .NET Framework versions on a Windows system.
- """
- import winreg
- def get_dotnet_frameworks():
- """
- Get installed .NET Framework versions.
- Returns:
- list: A list of installed .NET Framework versions.
- """
- dotnet_versions = []
- dotnet_release_keys = [
- (winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\NET Framework Setup\NDP"),
- (winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP")
- ]
- for hive, subkey in dotnet_release_keys:
- with winreg.OpenKey(hive, subkey, 0, winreg.KEY_READ) as key:
- subkey_names_count, _, _ = winreg.QueryInfoKey(key)
- for i in range(subkey_names_count):
- subkey_name = winreg.EnumKey(key, i)
- if subkey_name.startswith("v") and subkey_name not in dotnet_versions:
- dotnet_versions.append(subkey_name)
- return dotnet_versions
- def main():
- """
- Main function to retrieve installed .NET Framework versions and print them.
- """
- dotnet_versions = get_dotnet_frameworks()
- if dotnet_versions:
- print("Installed .NET Framework versions:")
- for version in dotnet_versions:
- print(f"- {version}")
- else:
- print("No .NET Frameworks found.")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement