Get build number of .exe file

Asked by Asheru on 2020-02-19


I want to know if it's possible to get the build number of an .exe file.

I have found some examples but they require win32com package and from what I have found it's not working with sikuliX since it's not written fully in python.

Is there any other way?

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
Manfred Hampl (m-hampl) said : #1

How would you do that without sikuli?

File explorer - navigate to the .exe file - right mouse button - properties - details

And these steps can of course be automated using sikuli.

RaiMan (raimund-hocke) said : #2

It is true, that you cannot use the Python package win32com, since The Python interpreter with SikuliX is the Java based Jython, which cannot access C-based stuff, as is possible with the Python interpreter.

But you can try using the package com.sun.jna.platform.win32, which is included in SikuliX, since we need it for various features, that need to access system API's like Win32.

You have to learn how to use Java classes from within Jython/SikuliX scripts and then the Win32 world is open for you ;-)

Asheru (asheru93) said : #3

@Manfred Hampl
Hmm, i wanted to avoid the use of images for this.

Ok then, it seems I have to to some research.

RaiMan (raimund-hocke) said : #4

if it is suitable (timing) then you might as well detach (subprocess.Popen) a "real" Python scriptrun where you use your Python/win32 knowHow.

Asheru (asheru93) said : #5

Ok but to be honest I have not clue how to do that.

RaiMan (raimund-hocke) said : #6

since "get the build number of an .exe file" is not part of my daily business ;-) I am sorry to leave you alone with that :-(

Asheru (asheru93) said : #7

I found a solution for this. Not the best but simple and quick (works for me).

So I have a script named "", that uses win32 package wich normally would not work executed from a sikuli script for printing the build number. Here is the code:

--from win32api import GetFileVersionInfo, LOWORD, HIWORD

def get_version_number (filename):
  info = GetFileVersionInfo (filename, "\\")
  ms = info['FileVersionMS']
  ls = info['FileVersionLS']
  return HIWORD (ms), LOWORD (ms), HIWORD (ls), LOWORD (ls)

if __name__ == '__main__':
  import os
  filename = os.environ["COMSPEC"]
  print (".".join ([str (i) for i in get_version_number (path_to_file)]))--

Then inside the sikuli script I have a function that looks like this:

--def get_build_number_from_exe_file():
            theproc = subprocess.Popen(path_to_file, shell = True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
            tmp =
            print tmp --

So what It does, it executes a python script that prints the build number in the console. Then it is read from the console and stored in 'tmp' variable.

Asheru (asheru93) said : #8

 **theproc = subprocess.Popen(, shell = True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

RaiMan (raimund-hocke) said : #9

clapping hands ;-)

I would not have it done better.

... you might even put the wanted exe-filename as a parameter to the Popen, when saying:
("python", "", "wanted-filename"), ...

and in the get the filename from sys.argv[1]

Can you help with this problem?

Provide an answer of your own, or ask Asheru for more information if necessary.

To post a message you must log in.