Old 17th January 2007, 09:13   #1
Junior Member
Join Date: Dec 2006
Posts: 35
.net again


if i unistall .net manually from Add/remove programs it do not remove the registry entries ...!!

isDotNetInstalled function shows .net is installed in this case...!!

what if somebody manually uninstall .net ?
kulakshay is offline   Reply With Quote
Old 18th January 2007, 06:07   #2
Join Date: Aug 2006
Posts: 86
This code is bit lengthier, However putting it in a text file messes it up.
I am not sure if you are using the same, but this works for me even if the .Net (2.0) uninstalled from control panel.


;Set .Net Framework version re-distributable has and to be checked for
!define DOT_MAJOR "2"
!define DOT_MINOR "0"
!define DOT_MINOR_MINOR "50727"


;This is a custom function required for checking the presence of the installed .Net framework.
;If the required .Net framework version not found it will launch the .Net framework MSI.
Function CheckDotNetFramework

Push $0
Push $1
Push $2
Push $3
Push $4
Push $5

StrCpy $0 "0"
StrCpy $1 "SOFTWARE\Microsoft\.NETFramework" ;registry entry to look in.
StrCpy $2 0

;Enumerate the versions installed.
EnumRegKey $3 HKLM "$1\policy" $2

;If we don't find any versions installed, it's not here.
StrCmp $3 "" noDotNet notEmpty

;We found something.
;Find out if the RegKey starts with 'v'.
;If it doesn't, goto the next key.
StrCpy $4 $3 1 0
StrCmp $4 "v" +1 goNext
StrCpy $4 $3 1 1

;It starts with 'v'. Now check to see how the installed major version
;relates to our required major version.
;If it's equal check the minor version, if it's greater,
;we found a good RegKey.
IntCmp $4 ${DOT_MAJOR} +1 goNext yesDotNetReg
;Check the minor version. If it's equal or greater to our requested
;version then we're good.
StrCpy $4 $3 1 3
IntCmp $4 ${DOT_MINOR} +1 goNext yesDotNetReg

;detect sub-version - e.g. 2.0.50727
;takes a value of the registry subkey - it contains the small version number
EnumRegValue $5 HKLM "$1\policy\$3" 0

IntCmpU $5 ${DOT_MINOR_MINOR} yesDotNetReg goNext yesDotNetReg

;Go to the next RegKey.
IntOp $2 $2 + 1
goto StartEnum

;Now that we've found a good RegKey, let's make sure it's actually
;installed by getting the install path and checking to see if the
;mscorlib.dll exists.
EnumRegValue $2 HKLM "$1\policy\$3" 0
;$2 should equal whatever comes after the major and minor versions
;(ie, v1.1.4322)
StrCmp $2 "" noDotNet
ReadRegStr $4 HKLM $1 "InstallRoot"
;Hopefully the install root isn't empty.
StrCmp $4 "" noDotNet
;build the actual directory path to mscorlib.dll.
StrCpy $4 "$4$3.$2\mscorlib.dll"
IfFileExists $4 yesDotNet noDotNet

;Nope, something went wrong along the way. Looks like the
;proper .NETFramework isn't installed.

;Un comment the following line to make this function throw a message box right away
; MessageBox MB_OK "You must have v${DOT_MAJOR}.${DOT_MINOR}.${DOT_MINOR_MINOR} or greater of the .NETFramework installed. Aborting!"
Call "InstallDotNetFramework"
; Abort
StrCpy $0 0
Goto done

;Everything checks out. Go on with the rest of the installation.
;MessageBox MB_OK "You have v${DOT_MAJOR}.${DOT_MINOR}.${DOT_MINOR_MINOR} or greater of the .NETFramework installed."
DetailPrint "Found .Net Framework v${DOT_MAJOR}.${DOT_MINOR}.${DOT_MINOR_MINOR} Installed, Skipping Installation."

FileOpen $9 "$WINDIR\Temp\ASA_Install.log" a
FileSeek $9 0 END
FileWrite $9 "$\r$\n»Found .Net Framework v${DOT_MAJOR}.${DOT_MINOR}.${DOT_MINOR_MINOR} Installed, Skipping Installation."
FileClose $9

StrCpy $0 1

Pop $4
Pop $3
Pop $2
Pop $1
Exch $0

n_baua is offline   Reply With Quote
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