Querying Current Software Version


Checking the current version of the application can be done in multiple manner depending fo the needs (without of without launching the software for example).

Checking Version via the executable

Substance Painter executable on Windows contains few informations that can be queried by external tools (such as Python).

Example in Python 3 (taken from here) : 

import os
import imp
import pip
import win32api #pypiwin32


#-------------------------------------------
#Reader
#-------------------------------------------
def getFileProperties(fname):
	"""
	Read all properties of the given file return them as a dictionary.
	"""
	propNames = ('Comments', 'InternalName', 'ProductName',
		'CompanyName', 'LegalCopyright', 'ProductVersion',
		'FileDescription', 'LegalTrademarks', 'PrivateBuild',
		'FileVersion', 'OriginalFilename', 'SpecialBuild')

	props = {'FixedFileInfo': None, 'StringFileInfo': None, 'FileVersion': None}

	try:
		# backslash as parm returns dictionary of numeric info corresponding to VS_FIXEDFILEINFO struc
		fixedInfo = win32api.GetFileVersionInfo(fname, '\\')
		props['FixedFileInfo'] = fixedInfo
		props['FileVersion'] = "%d.%d.%d.%d" % (fixedInfo['FileVersionMS'] / 65536,
			fixedInfo['FileVersionMS'] % 65536, fixedInfo['FileVersionLS'] / 65536,
			fixedInfo['FileVersionLS'] % 65536)

		# \VarFileInfo\Translation returns list of available (language, codepage)
		# pairs that can be used to retreive string info. We are using only the first pair.
		lang, codepage = win32api.GetFileVersionInfo(fname, '\\VarFileInfo\\Translation')[0]

		# any other must be of the form \StringfileInfo\%04X%04X\parm_name, middle
		# two are language/codepage pair returned from above

		strInfo = {}
		for propName in propNames:
			strInfoPath = u'\\StringFileInfo\\%04X%04X\\%s' % (lang, codepage, propName)
			## print str_info
			strInfo[propName] = win32api.GetFileVersionInfo(fname, strInfoPath)
			
		props['StringFileInfo'] = strInfo
	except:
		pass

	return props


#-------------------------------------------
#Check exe
#-------------------------------------------
Path = "E:/Software/Painter/Substance Painter.exe"

FileInfo = getFileProperties(Path)

print( FileInfo )
Will output :
E:\Software\Painter>query.py
{'FixedFileInfo': {'Signature': -17890115, 'StrucVersion': 65536, 'FileVersionMS': 132251649, 'FileVersionLS': 65536, 'ProductVersionMS': 132251649, 'ProductVersionLS': 65536, 'FileFlagsMask': 0, 'FileFlags': 0, 'FileOS': 0, 'FileType': 1, 'FileSubtype': 0, 'FileDate': None}, 'StringFileInfo': {'Comments': None, 'InternalName': 'Substance Painter', 'ProductName': 'Substance Painter', 'CompanyName': 'Allegorithmic', 'LegalCopyright': 'Copyright (C) 2017 Allegorithmic', 'ProductVersion': '2018.1.1', 'FileDescription': 'Substance Painter 2018.1.1', 'LegalTrademarks': None, 'PrivateBuild': None, 'FileVersion': '2018.1.1', 'OriginalFilename': 'Substance Painter.exe', 'SpecialBuild': None}, 'FileVersion': '2018.1.1.0'}
Checking Version via Command Line

You can use command line as following : substance painter.exe command_name [option]

To ask the version use --version, -v.

Note that the command line actions of Substance Painter will output a window.

Checking Version via Scripting

The scripting API (available via the help menu) allow to query the current version of the application.

Take a look at the namespace "alg" for further details.

Example :

//Print current version in the log window (string)
alg.log.info( alg.version.painter );