Get IE version for Net Framework: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author links.)
mNo edit summary
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
{|align=right
{{PageAuthor|sunjammer}}
|<small>Author: [[{{ns:2}}:sunjammer|sunjammer]] ([[{{ns:3}}:sunjammer|talk]], [[{{ns:-1}}:Contributions/sunjammer|contrib]])</small>
 
|}
<br style="clear:both;">
== Description ==
== Description ==
In [http://forums.winamp.com/showthread.php?postid=816695#post816695 this post] on the [http://forums.winamp.com/forumdisplay.php?s=63e6dedf6b1c37dbd2d815e2a323094e&forumid=65 Official NSIS Forum], the user [[user:robdal | robdal]] gave his full script (which is at the end of the page) and some explanatory comments...:
In [http://forums.winamp.com/showthread.php?postid=816695#post816695 this post] on the [http://forums.winamp.com/forumdisplay.php?s=63e6dedf6b1c37dbd2d815e2a323094e&forumid=65 Official NSIS Forum], the user [[user:robdal | robdal]] gave his full script (which is at the end of the page) and some explanatory comments...:
Line 84: Line 82:
;GetIEVersion
;GetIEVersion
;
;
; Based on Yazno's function, [url]http://yazno.tripod.com/powerpimpit/[/url]
; Based on Yazno's function
; Returns on top of stack
; Returns on top of stack
; 1-6 (Installed IE Version)
; 1-6 (Installed IE Version)
Line 149: Line 147:
   Exch $R2
   Exch $R2
FunctionEnd</highlight-nsis>
FunctionEnd</highlight-nsis>
[[Category:Other Products Version Detection Functions]]

Latest revision as of 08:38, 4 December 2005

Author: sunjammer (talk, contrib)


Description

In this post on the Official NSIS Forum, the user robdal gave his full script (which is at the end of the page) and some explanatory comments...:

I'll explain the purpose of this script:

  1. We have our own installer (written in C#: SharpInstaller.exe) that is able to perform some checks tailored to our software.
  2. We need to be sure that our customers have the required Net Framework installed.
  3. A pre-requisite of the .Net Framework is IE 5.01.

The script checks for the IE version:

  1. if we get 6 we jump to the label IEOK.
  2. if we get 4, 3, 2 or 1 we jump to the label IEKO, if we get 5 we jump to the lbl_IE5.
  3. In lbl_IE5 we check to see if we got 5.00 (the only case in which a version 5 is not enough) then we jump to lbl_IEKO.
  4. the lbl_IEKO should launch the installation of IE 6. In our case we launch a program that will take care of that and would give an explanation of what's going on to the user.

If the user has a good enough version of IE, then we check for the .Net Framework. In our case we check for a very specific subkey, which is the version we distribute (Italian version of .Net Framework). The logic followed is the same for IE: we launch a program that explains something to the user (during the installation of .Net Framework it appears as if the PC is not working and it can last up to 10 minutes in older PC's)

I realize that our script is not well written and a bit chaotic, but i guess that a more expert NSIS user might make it more readable.

best regards
Roberto DALMONTE

Usage

The following is taken from this post by robdal:

[W]e had to change a bit the GetIEVersion. The problem is that the .Net Framework accepts as a good one the IE5 version that comes with Win2000 sp2(IE 5.01), but requires a greater version of IE if you happen to have Win98 second edition (IE 5.00). So we found a key in the registry in order to check if you need to update IE or not.

ReadRegStr $R0 HKLM "Software\Microsoft\Internet Explorer\Version Vector" "IE" 
Strcpy $R0 $R0 4; we need to check for 5.01 or 5.00 so 4 chars

NSIS is excellent.
Our best compliments.

The Script

SilentInstall silent
OutFile "example1st.exe"
Section "MySection"
   Call GetIEVersion
   Pop $R0
   MessageBox MB_OK $R0
   Push $R1
   StrCpy $R1 $R0 1
   MessageBox MB_OK $R1
   StrCmp $R1 '6' lbl_IEOK
   StrCmp $R1 '5' lbl_IE5
   StrCmp $R1 '4' lbl_IEKO
   StrCmp $R1 '2' lbl_IEKO
   StrCmp $R1 '3' lbl_IEKO
   StrCmp $R1 '1' lbl_IEKO
 
   lbl_IE5:
      StrCmp $R0 '5.00'lbl_IEKO
      Goto lbl_IEOK
   lbl_IEOK:
      MessageBox MB_OK "OK"
      goto lbl_NETFRAMEWORK
   lbl_IEKO:
      MessageBox MB_OK "KO"
      Exec '"CamIE.exe" '
      goto lbl_done
   lbl_NETFRAMEWORK:
      Call GetNetFramework
      Pop $R2
      StrCmp $R2 'OK' lbl_NETOK
      StrCmp $R2 'KO' lbl_NETKO
 
   lbl_NETOK:
      MessageBox MB_OK "poco prima di SharpInstaller"
      Exec '"SharpInstaller.exe" '
      goto lbl_done
   lbl_NETKO:
      MessageBox MB_OK "poco prima di camnet"
      Exec '"NET\CamNET.exe" '
      goto lbl_done
   lbl_done:
 
SectionEnd ; end the section
 
;GetIEVersion
;
; Based on Yazno's function
; Returns on top of stack
; 1-6 (Installed IE Version)
; or
; '' (IE is not installed)
;
; Usage:
;   Call GetIEVersion
;   Pop $R0
;   ; at this point $R0 is "5" or whatnot
 
Function GetIEVersion
   Push $R0
   ClearErrors
   ReadRegStr $R0 HKLM "Software\Microsoft\Internet Explorer" "Version"
   IfErrors lbl_123 lbl_456
 
   lbl_456: ; ie 4+
      ReadRegStr $R0 HKLM "Software\Microsoft\Internet Explorer\Version Vector" "IE"   
      Strcpy $R0 $R0 4
      Goto lbl_done
 
   lbl_123: ; older ie version
      ClearErrors
      ReadRegStr $R0 HKLM "Software\Microsoft\Internet Explorer" "IVer"
      IfErrors lbl_error
 
      StrCpy $R0 $R0 3
      StrCmp $R0 '100' lbl_ie1
      StrCmp $R0 '101' lbl_ie2
      StrCmp $R0 '102' lbl_ie2
 
      StrCpy $R0 '3' ; default to ie3 if not 100, 101, or 102.
      Goto lbl_done
      lbl_ie1:
         StrCpy $R0 '1'
         Goto lbl_done
      lbl_ie2:
         StrCpy $R0 '2'
         Goto lbl_done
      lbl_error:
         StrCpy $R0 ''
      lbl_done:
   Exch $R0
FunctionEnd
;Get.NetFramework
 
Function GetNetFramework
   Push $R2
   ClearErrors
   ReadRegStr $R2 HKLM \
   "SOFTWARE\Microsoft\NET Framework Setup\Product\Microsoft .NET Framework Full v1.0.3705 (1040)" \
   "Version"
   IfErrors lbl_Err lbl_OK
 
   lbl_OK: ; .NET OK
	StrCpy $R2 'OK'
	Goto lbl_done
 
   lbl_ERR: ; NO NET
	StrCpy $R2 'KO'
	Goto lbl_done
   lbl_done:
   Exch $R2
FunctionEnd