Page 1 of 1

Truncate the text

Published: January 9, 2024 - 3:10 PM
by cefinformatique
Good morning,

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')
What command should I use instead of trim?

Re: Truncating text

Published: January 9, 2024 - 4:11 PM
by sfonteneau
Good morning

Like this, simply use Version

Code: Select all

myversion = "1.2.3.4.5.6.7"
Version('myversion',4)