I have installed the python module pywin32 (-m pip install --upgrade pywin32) I want to know the version of a .exe using this module. I search on internet and I always find the same code sample that I'm using:
from win32com.client import Dispatch
def get_version_number(file_path):
information_parser = Dispatch("Scripting.FileSystemObject")
version = information_parser.GetFileVersion(file_path)
return version
file_path = r'C:\Users\Alex\Downloads\ChromeSetup.exe'
version = get_version_number(file_path)
print(version)
I have this error message:
version = information_parser.GetFileVersion(file_path)
File "<COMObject Scripting.FileSystemObject>", line 3, in GetFileVersion
pywintypes.com_error: (-2147352567, 'Ocurrió una excepción.', (0, None, None, None, 0, -2147024894), None)
I don't know the problem, it happens with any .exe. What is happening? Any solution? Thanks.
try this:
It uses the win32 api instead of the com one