0

I have been using a little NSIS script for a few years that grabs the version of the EXE so I can display it in the installers welcome text.

I got the script here: http://nsis.sourceforge.net/Invoking_NSIS_run-time_commands_on_compile-time

!define File "C:\MyFile.exe"

OutFile "GetVersion.exe"
SilentInstall silent

Section

 ## Get file version
 GetDllVersion "${File}" $R0 $R1
  IntOp $R2 $R0 / 0x00010000
  IntOp $R3 $R0 & 0x0000FFFF
  IntOp $R4 $R1 / 0x00010000
  IntOp $R5 $R1 & 0x0000FFFF
  StrCpy $R1 "$R2.$R3.$R4.$R5"

 ## Write it to a !define for use in main script
 FileOpen $R0 "$EXEDIR\Version.txt" w
  FileWrite $R0 '!define Version "$R1"'
 FileClose $R0

SectionEnd

Recently I started using UPX to compress the EXE of the application.

Now that it is UPX compressed, the file version script no longer works, I'm guessing due to non standard header layout.

How can I read the file version from a UPX compressed EXE?

UPDATE: This is closed now but I discovered later this is likely to do with some kind of elevated permissions issue and running the command over a mapped drive.

4

1 回答 1

1

即使在UPX --ultra-brute test.exe我尝试使用版本信息块时也没有被压缩。您是否使用特殊的 UPX 开关?你试过--keep-resource=%resourceid%吗?

如果您使用的是 NSIS v3,您可以使用!getdllversion在编译时获取版本,而无需使用!system.

于 2015-05-22T17:51:22.410 回答