What is the best way to truncate a version number?
In my case, I need to obtain the version number of the installed software via the registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\EIC\REVAO\VersionPosteComplete (REG_SZ).
This software releases a major version annually, followed by patches throughout the rest of the year. The current major version number is 6.21.0.0, and the latest patch number is 6.21.20.0
Therefore, I first need to check if the registry key version number starts with 6.21 in order to know whether I should apply the major update or just the latest patch.
Therefore, I intend to proceed based on this principle:
Code: Select all
latestversion = '6.21.20.0'
def install():
if trim(registry_readstring(HKEY_LOCAL_MACHINE, r'SOFTWARE\WOW6432NODE\EIC\REVAO','VersionPosteComplete'),4) > trim(latestversion,4)
print('installation du dernier patch')
else:
print('installation de la dernière version majeure puis du dernier patch')