- NSIS Discussion
- A little help would be appriciated
Archive: A little help would be appriciated
TonyDS
5th August 2003 18:55 UTC
A little help would be appriciated
Before installation of My NSIS program is it possible to check the version of an exisiting exe to see if its the correct version?
I don't really mean by checking it through the Reg though, as this does not show the correct version info.
The original game is version 1.0.0.0, there are two updates for this game which will change the version to 2.0.0.1 or 2.0.0.2
I only want my NSIS program to install if the version is 2.0.0.2 otherwize you will get a message saying that you will need to update the game before you can install my NSIS program then quit
If it is the correct version it will install normally
At the momment My NSIS program checks the reg to see if the game is the correct version then installs
using this bit of script
onInit
ReadRegStr$0 HKLM "SOFTWARE\\Game software\\v1.0" "Version"
>IntCmp $0 1 +1 +1 +3
MessageBox MB_ICONINFORMATION
|MB_OK "WARNING: GAME needs to be updated to version 2.02."
>Abort
FunctionEnd
>
This is fine, but my NSIS program will install if the Games 2.01 update has been installed, which will bugger up the entire installation and make the game unplayable
See in the Reg the "version" is either 1 for the original or 2 if either update has been added.
Which makes checking the reg pointless
Like I said the only real way to check this would be from the Games EXE as this shows the true version.
Any help would be greatly appriciated plus showing me how the script should look
Thanks in advance
-Tony
Joost Verburg
5th August 2003 18:58 UTC
So you need to check the version information resource? It could be possible using the System plug-in or you can write your own plug-in.
Is there no registry key / configuration file available with the version number?
TonyDS
5th August 2003 19:19 UTC
Yes it shows the version number
HKLM "SOFTWARE\Game software\v1.0" "Version" 1.0
but if the game updates are applied it only shows to 2.0
so even if the 2.01 patch is install my program will still install, which I don't want it to do
Thats why I would like to check the exe which shows the exact version.
As I'm new to all this I have no way of knowing how to write a plug-in or which commands to use if any
sorry, just a thick noobie
Afrow UK
5th August 2003 21:16 UTC
NSIS plugins are usually written in C++/Delphi.
If you do not know about creating you're own plugin, then the System plugin will do your job.
You should also try using the SysInfo plugin (get on NSIS Archive) which can get the version of specified files.
-Stu
TonyDS
5th August 2003 22:03 UTC
I don't know how to use it though :(
This is the reason, I'm asking for help
Its not too much to ask
Afrow UK
5th August 2003 22:24 UTC
http://nsis.sourceforge.net/archive/...ysinfo.dll.zip
Extract just the dll to your Plugins dir.
Now, in your script use:
sysinfo::GetFileVersion "x:\path\to\exe"
Pop $0 ;file version
If $0 is empty ("") then try:
sysinfo::GetFileVersionValue "FileVersion" "x:\path\to\exe"
Pop $0 ;file version
-Stu
TonyDS
6th August 2003 03:10 UTC
Thanks for pointing me in the right direction Afrow UK :)
I figured out how to use the script you provided
but the next bit was a liitle harder
onInit
sysinfo
::GetFileVersion "x:\\path\to\\exe"
>Pop $0
StrCmp$0 "2.0.0.2" +3
MessageBox MB_ICONINFORMATION|MB_OK "The Game has not yet been updated to version 2.02."
>Abort
FunctionEnd
>
It was this bit
StrCmp $0 "2.0.0.2" +3 that had me a little perplexed, it's taken me around 3 hrs just to figure that line out.
Tried god knows how many differrent combinations of IntCmp, IntCmpU, StrCpy plus a few others, I was about to give up on it, when I came upon the combination above which works.
So once again thanks :D
Afrow UK
6th August 2003 10:42 UTC
Just a thought, what happens if 2.0.0.3 comes out.
You're installer will think that the user has an older version.
You should remove the dot (.) from the version, and use IntCmp instead.
To remove the dots, use the StrReplace function:
Push $0 ;input
Push "." ;to replace
Push "" ;replace with nothing (remove)
Call StrReplace
Pop $0
IntCmp $0 2002 +3 0 +3
MessageBox MB_ICONINFORMATION|MB_OK "The Game has not yet been updated to version 2.02."
Abort
IntCmp works like this:
IntCmp $0 2002 [goto if $0=2002] [goto if $0<2002] [goto if $0>2002]
-Stu
Sunjammer
6th August 2003 13:29 UTC
How about using the code Smile2Me created ages ago to compare dotted versions?
http://nsis.sourceforge.net/archive/....php?pageid=57
SteelCoder
6th August 2003 13:51 UTC
If the executable has an actual 'version' resource in it (and it's maintained correctly), Couldn't you use GetDLLVersion?
ramon18
6th August 2003 15:40 UTC
Yes, you can use GetDLLVersion, for example you can use the previous uninstall.exe version info, by detecting the file location through the registry and than decide if the update can run or not.
good luck
SteelCoder
6th August 2003 18:41 UTC
Why not just compare the version of the file you are going to install verses the file that is installed? Just like upgrading a DLL.
TonyDS
6th August 2003 20:19 UTC
No chance of a update to 2.0.0.3 unless a miricale happens
It's a oldish game
The code know looks like this
Function .onInit
sysinfo::GetFileVersion "x:\path\to\exe"
Pop $0
Push $0 ;input
Push "." ;to replace
Push "" ;replace with nothing (remove)
Call StrReplace
Pop $0
IntCmp $0 2002 +3 0 +3
MessageBox MB_ICONINFORMATION|MB_OK "The Game has not yet been updated to version 2.02."
Abort
FunctionEnd
With the StrReplace script underneath it
Hope this is what you meant, it works anyhow thanks again :)
Thanks again Afrow
Sunjammer I looked at the code you suggested, thanks, but Afrow's code is fine.