nsnb
24th May 2009 17:55 UTC
Read FileVersion of Windows EXE on Linux
This is not really an NSIS question but knowing the great minds here and given that my Windows EXE is generated by NSIS, I am hoping to find a hint or tip here (I combed the web but found no answer, yet):
I would like to be able to extract, using a bash script running on Linux, the FileVersion information embedded in my NSIS installers. The idea is that the bas script will call an external program that actually extract thatFileVersion info.
So far, I only managed to use 'strings':
strings -e l mywindowsexename.exe
Which results in two separate lines for FileVersion and its information. Thus a simple line manipulation program such as grep or sed won't suffice.
Any tip or pointer to how to accomplish this?
Thanks.
Pidgeot
24th May 2009 18:55 UTC
It's no different to extracting it from any other Windows executable; there is nothing special about the way NSIS does it.
The information is stored as a resource in the executable, as described at http://msdn.microsoft.com/en-us/library/aa381058.aspx. So what you need is a way to navigate the resources in executables - I believe http://msdn.microsoft.com/en-us/magazine/bb985992.aspx and http://msdn.microsoft.com/en-us/magazine/cc301808.aspx will get you far with this part.
Once you know the format, it should be (relatively) trivial to write this external program in C or some other langauge.
nsnb
24th May 2009 19:46 UTC
Thanks, Pidgeot. I was actually looking for a shortcut that doesn't involve a programming mini-project. I just came up with a one-liner that seems to work. I am posting it here for the benefit of all:
strings -e l mywindowsinstaller.exe | sed -e :a -e '/FileVersion$/N; s/FileVersion\n/FileVersion /; ta' | grep FileVersion | cut -d ' ' -f 2
:)