Old 24th May 2009, 17:55   #1
nsnb
Senior Member
 
Join Date: Jul 2008
Posts: 157
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':
code:
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.
nsnb is offline   Reply With Quote
Old 24th May 2009, 18:55   #2
Pidgeot
Senior Member
 
Pidgeot's Avatar
 
Join Date: Jan 2002
Location: Denmark
Posts: 136
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.
Pidgeot is offline   Reply With Quote
Old 24th May 2009, 19:46   #3
nsnb
Senior Member
 
Join Date: Jul 2008
Posts: 157
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:
code:
strings -e l mywindowsinstaller.exe | sed -e :a -e '/FileVersion$/N; s/FileVersion\n/FileVersion /; ta' | grep FileVersion | cut -d ' ' -f 2


nsnb is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump