- NSIS Discussion
- Check for OS version not working
Archive: Check for OS version not working
ritesh
21st July 2005 09:33 UTC
Check for OS version not working
Hello,
I think I am doing some major screwup. I want on .dll to be installed only if its Win98, Win2K or WinMP. I use the following script.
Section "System Files (98 Only)" SecWin98
File "..\lib\gdiplus.dll"
>SectionEnd
Section"System Files (ME Only)" SecWinME
File "..\lib\gdiplus.dll"
>SectionEnd
Section"System Files (ME Only)" SecWin2K
File "..\lib\gdiplus.dll"
>SectionEnd
>
Still it installs gdiplus.dll on WinXP box too! I know I am doing something stupid :(
BTW, I have 2 more questions:
1.) Is there any way to specify to install gdiplus.dll if the OS is not WinXP and Win2003?
2.) Is there anyway to stop installation after showing a message if the OS is Win95?
Thanks.
Yathosho
21st July 2005 11:02 UTC
from the excerpt of your script i can't help you. seems like don't check for the windows version, but leave it to the user. there's a funtion to get the windows version in the Wiki.
ritesh
21st July 2005 11:20 UTC
Thanks.
Find attached the script file. Maybe you can help me now with my problem.
Basically I want to copy gdiplus.dll if its NOT WinXP and Win2K3.
Also would like to stop installation when its Win95.
Afrow UK
21st July 2005 12:04 UTC
Use the function that Yathosho gave you a link to.
-Stu
ritesh
25th July 2005 16:44 UTC
Hi
I used the plugin and the function but still couldnt get the script working. Its getting compiled but GdiPLus.dll is getting installed irespective of the underlying OS.
I am attaching the script file. Can somebody tell me whats the problem.
Ritesh
ritesh
26th July 2005 09:11 UTC
Hello,
I worked on it a little more and now I am correctly able to decide the OS and if the OS needs to have Gdiplus.dll installed, I am defining a macro INCLUDE_GDI
e.g.
Function .onInit
.................
ItIsNotWindows2003:
!define INCLUDE_GDI
Done:
FunctionEnd
Now in my section, Section "Executables" SEC01, I am having a line:
!ifdef INCLUDE_GDI
File "..\lib\gdiplus.dll"
!endif
Now irrespective of Windows, gdiplus is always installed. I think I am doing something wrong?
Thx in advance.
Yathosho
26th July 2005 09:35 UTC
!define is a compile time command, so this does not work. you could use something like this:
IsIsNotWindows95:
; check if its windows XP
Version::IsWindowsXP
; get the result
Pop $TempResult
; check result
StrCmp $TempResult "1" 0 ItIsNotWindowsXP
StrCpy $DontCopy "1"
Goto Go2
ItIsNotWindowsXP:
; check if its windows XP
Version::IsWindows2003
; get the result
Pop $TempResult
; check result
StrCmp $TempResult "1" 0 Go2
StrCpy $DontCopy "1"
Goto Go2
later you can query the variable DontCopy
StrCmp $DontCopy "1" +2
File "..\lib\gdiplus.dll"
ritesh
26th July 2005 12:01 UTC
Still does not seem to work. I am attaching the .nsi file. Can you tell me whats wrong?
I have checked it in WinXP and it copies GdiPlus.dll. Basically I dont want to copy in WinXP and Win2003.
Afrow UK
26th July 2005 13:04 UTC
You really don't need to use the Version plugin. You can just as easily use the GetWindowsVersion function instead (in NSIS Documentation under Useful Scripts).
Also, as you're only trying to skip one file, it's a waste of memory declaring a variable that will only be used once.
Do:
Call GetWindowsVersion
Pop $R0
StrCmp $R0 XP +3
StrCmp $R0 2000 +2
File "..\lib\gdiplus.dll"
-Stu
ritesh
26th July 2005 14:59 UTC
Added the above code in, Executables section and while compilation it throws me an error:
Processed 1 file, writing output:
>Adding plug-ins initializing function... Done!
>Error: resolving install function "GetWindowsVersion" in install section "Executables" (0)
>Note: uninstall functions must begin with "un.", and install functions must not
Error- aborting creation process
>
Afrow UK
26th July 2005 16:21 UTC
Have you put the GetWindowsVersion function in your script??
-Stu
ritesh
26th July 2005 16:30 UTC
Sorry, I didnt put it!
Now I copy-paste the function from the NSIS help file and it gets compiled correctly. Sadly, gdiplus.dll is still getting copied in my WinXP machine.
Find attached the latest nsi.
Afrow UK
26th July 2005 16:33 UTC
Ok, change:
Call GetWindowsVersion
Pop $R0
To:
Call GetWindowsVersion
Pop $R0
MessageBox MB_OK $R0
And tell me what it says.
Did you make sure that you deleted "gdiplus.dll" first?
-Stu
ritesh
26th July 2005 16:39 UTC
Yup, I made sure that gdiplus.dll was deleted.
Funnily - the messaged box has BLANK string.
Find attached the Screenshot!
Afrow UK
26th July 2005 16:50 UTC
Interesting. That would probably mean the registry entry that identifies your Windows installation is missing.
Try the GetVersion plugin (put DLL in your Plugins folder):
http://nsis.sourceforge.net/wiki/File:GetVersion.zip
Then you want to use:
GetVersion::WindowsName
Pop $R0
StrCmp $R0 "Windows XP" +3
StrCmp $R0 "Windows Server 2003" +2
File "..\lib\gdiplus.dll"
The plugin gets the information from API call rather than the registry.
-Stu
ritesh
26th July 2005 17:00 UTC
OK! That worked. Thanks for the help!
Really, appreciated!