Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   .NET 2.0 install function (http://forums.winamp.com/showthread.php?t=243765)

Gridley 17th April 2006 20:28

.NET 2.0 install function
 
I use the GetDotNET code to detect which version of .NET framework is installed, but rather than

I have a desire to convert this page to a function instead of a section. So far, I can't get it to work...could someone help?

Thanks in advance!

Afrow UK 17th April 2006 22:04

Do you need to call it before the InstFiles page?
What happens if you just change the Section and SectionEnd to Function and FunctionEnd?

-Stu

Gridley 18th April 2006 00:35

Quote:

Originally posted by Afrow UK
Do you need to call it before the InstFiles page?
What happens if you just change the Section and SectionEnd to Function and FunctionEnd?

-Stu

I'd like to call it immediately so that I don't need to worry about uninstalling the partial install, though I could work around that.

Essentially what I have done is pretty much just replace "Section" with "Function" - the GetDotNETVersion routines work great, the MB for whether to download .net or abort opens, then regardless of choice, the installer aborts.

Here's my code currently:

DECLARATIONS (partial):
code:

; FetchDotNET VARs
Var "LANGUAGE_DLL_TITLE"
Var "LANGUAGE_DLL_INFO"
Var "URL_DOTNET"
Var "OSLANGUAGE"
Var "DOTNET_RETURN_CODE"
LangString DESC_REMAINING ${LANG_ENGLISH} " (%d %s%s remaining)"
LangString DESC_PROGRESS ${LANG_ENGLISH} "%d.%01dkB/s" ;"%dkB (%d%%) of %dkB @ %d.%01dkB/s"
LangString DESC_PLURAL ${LANG_ENGLISH} "s"
LangString DESC_HOUR ${LANG_ENGLISH} "hour"
LangString DESC_MINUTE ${LANG_ENGLISH} "minute"
LangString DESC_SECOND ${LANG_ENGLISH} "second"
LangString DESC_CONNECTING ${LANG_ENGLISH} "Connecting..."
LangString DESC_DOWNLOADING ${LANG_ENGLISH} "Downloading %s"
LangString DESC_SHORTDOTNET ${LANG_ENGLISH} "Microsoft .Net Framework 2.0"
LangString DESC_LONGDOTNET ${LANG_ENGLISH} "Microsoft .Net Framework 2.0"
LangString DESC_DOTNET_DECISION ${LANG_ENGLISH} "$(DESC_SHORTDOTNET) is required.$\nIt is strongly \
advised that you install$\n$(DESC_SHORTDOTNET) before continuing.$\nIf you choose to continue, \
you will need to connect$\nto the internet before proceeding.$\nWould you like to continue with \
the installation?"
LangString SEC_DOTNET ${LANG_ENGLISH} "$(DESC_SHORTDOTNET) "
LangString DESC_INSTALLING ${LANG_ENGLISH} "Installing"
LangString DESC_DOWNLOADING1 ${LANG_ENGLISH} "Downloading"
LangString DESC_DOWNLOADFAILED ${LANG_ENGLISH} "Download Failed:"
LangString ERROR_DOTNET_DUPLICATE_INSTANCE ${LANG_ENGLISH} "The $(DESC_SHORTDOTNET) Installer is \
already running."
LangString ERROR_NOT_ADMINISTRATOR ${LANG_ENGLISH} "$(DESC_000022)"
LangString ERROR_INVALID_PLATFORM ${LANG_ENGLISH} "$(DESC_000023)"
LangString DESC_DOTNET_TIMEOUT ${LANG_ENGLISH} "The installation of the $(DESC_SHORTDOTNET) \
has timed out."
LangString ERROR_DOTNET_INVALID_PATH ${LANG_ENGLISH} "The $(DESC_SHORTDOTNET) Installation$\n\
was not found in the following location:$\n"
LangString ERROR_DOTNET_FATAL ${LANG_ENGLISH} "A fatal error occurred during the installation$\n\
of the $(DESC_SHORTDOTNET)."
LangString FAILED_DOTNET_INSTALL ${LANG_ENGLISH} "The installation of $(PRODUCT_NAME) will$\n\
continue. However, it may not function properly$\nuntil $(DESC_SHORTDOTNET)$\nis installed."



.oninit:
code:

Function .onInit
Call GetDotNETVersion
Pop $0
${If} $0 == "not found"
;MessageBox MB_ICONSTOP|MB_YESNO|MB_DEFBUTTON2 ".NET framework is not installed. \
Select Yes to download and install .NET 2.0 or NO to abort." IDYES +2
;Abort
call FetchDotNET
${EndIf}

StrCpy $0 $0 "" 1 # skip "v"

${VersionCompare} $0 "2.0" $1
${If} $1 == 2
;MessageBox MB_ICONSTOP|MB_YESNO|MB_DEFBUTTON2 ".NET framework v2.0 or newer is required. You have $0. \
Select Yes to download and install .NET 2.0 or NO to abort." IDYES +2
call FetchDotNET
${EndIf}
FunctionEnd



Function GetDotNETVersion:
code:

Function GetDotNETVersion
Push $0
Push $1

System::Call "mscoree::GetCORVersion(w .r0, i ${NSIS_MAX_STRLEN}, *i) i .r1"
StrCmp $1 0 +2
StrCpy $0 "not found"

Pop $1
Exch $0
FunctionEnd



Function FetchDotNET Converted from zimsms "Installing .NET" wiki page:
code:

Function FetchDotNET
; .NET Framework
!define BASE_URL http://download.microsoft.com/download
; English
!define URL_DOTNET_1033 "${BASE_URL}/a/a/c/aac39226-8825-44ce-90e3-bf8203e74006/dotnetfx.exe"
; German
!define URL_DOTNET_1031 "${BASE_URL}/4/f/3/4f3ac857-e063-45d0-9835-83894f20e808/dotnetfx.exe"
; Spanish
!define URL_DOTNET_1034 "${BASE_URL}/8/f/0/8f023ff4-2dc1-4f10-9618-333f5b9f8040/dotnetfx.exe"
; French
!define URL_DOTNET_1036 "${BASE_URL}/e/d/a/eda9d4ea-8ec9-4431-8efa-75391fb91421/dotnetfx.exe"
; Portuguese (Brazil)
!define URL_DOTNET_1046 "${BASE_URL}/8/c/f/8cf55d0c-235e-4062-933c-64ffdf7e7043/dotnetfx.exe"
; Chinese (Simplified)
!define URL_DOTNET_2052 "${BASE_URL}/7/b/9/7b90644d-1af0-42b9-b76d-a2770319a568/dotnetfx.exe"
; Japanese
!define URL_DOTNET_1041 "${BASE_URL}/5/6/7/567758a3-759e-473e-bf8f-52154438565a/dotnetfx.exe"
; ... If you need one not listed above you will have to visit the Microsoft Download site,
; select the language you are after and scan the page source to obtain the link.

; the following Goto and Label is for consistencey.
Goto lbl_DownloadRequired
lbl_DownloadRequired:
!insertmacro PRINT "$(DESC_DOWNLOADING1) $(DESC_SHORTDOTNET)..."
MessageBox MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2 "$(DESC_DOTNET_DECISION)" /SD IDYES IDYES +2
Abort
; "Downloading Microsoft .Net Framework"
NSISdl::download /TRANSLATE "$(DESC_DOWNLOADING)" "$(DESC_CONNECTING)" "$(DESC_SECOND)" "$(DESC_MINUTE)" "$(DESC_HOUR)" "$(DESC_PLURAL)" \
"$(DESC_PROGRESS)" "$(DESC_REMAINING)" /TIMEOUT=30000 "$URL_DOTNET" "$TEMP\dotnetfx.exe"
Pop $0
StrCmp "$0" "success" lbl_continue
!insertmacro PRINT "$(DESC_DOWNLOADFAILED) $0"
Abort

lbl_continue:
!insertmacro PRINT "$(DESC_INSTALLING) $(DESC_SHORTDOTNET)..."
Banner::show /NOUNLOAD "$(DESC_INSTALLING) $(DESC_SHORTDOTNET)..."
nsExec::ExecToStack '"$TEMP\dotnetfx.exe" /q /c:"install.exe /noaspupgrade /q"'
pop $DOTNET_RETURN_CODE
Banner::destroy
SetRebootFlag true
; silence the compiler
Goto lbl_NoDownloadRequired
lbl_NoDownloadRequired:

; obtain any error code and inform the user ($DOTNET_RETURN_CODE)
; If nsExec is unable to execute the process,
; it will return "error"
; If the process timed out it will return "timeout"
; else it will return the return code from the executed process.
StrCmp "$DOTNET_RETURN_CODE" "" lbl_NoError
StrCmp "$DOTNET_RETURN_CODE" "0" lbl_NoError
StrCmp "$DOTNET_RETURN_CODE" "3010" lbl_NoError
StrCmp "$DOTNET_RETURN_CODE" "8192" lbl_NoError
StrCmp "$DOTNET_RETURN_CODE" "error" lbl_Error
StrCmp "$DOTNET_RETURN_CODE" "timeout" lbl_TimeOut
; It's a .Net Error
StrCmp "$DOTNET_RETURN_CODE" "4101" lbl_Error_DuplicateInstance
StrCmp "$DOTNET_RETURN_CODE" "4097" lbl_Error_NotAdministrator
StrCmp "$DOTNET_RETURN_CODE" "1633" lbl_Error_InvalidPlatform lbl_FatalError
; all others are fatal

lbl_Error_DuplicateInstance:
!insertmacro PRINT "$(ERROR_DOTNET_DUPLICATE_INSTANCE)"
GoTo lbl_Done

lbl_Error_NotAdministrator:
!insertmacro PRINT "$(ERROR_NOT_ADMINISTRATOR)"
GoTo lbl_Done

lbl_Error_InvalidPlatform:
!insertmacro PRINT "$(ERROR_INVALID_PLATFORM)"
GoTo lbl_Done

lbl_TimeOut:
!insertmacro PRINT "$(DESC_DOTNET_TIMEOUT)"
GoTo lbl_Done

lbl_Error:
!insertmacro PRINT "$(ERROR_DOTNET_INVALID_PATH)"
GoTo lbl_Done

lbl_FatalError:
!insertmacro PRINT "$(ERROR_DOTNET_FATAL)[$DOTNET_RETURN_CODE]"
GoTo lbl_Done

lbl_Done:
!insertmacro PRINT "$(FAILED_DOTNET_INSTALL)"
lbl_NoError:

FunctionEnd



Now, I know I'm just missing something simple, or maybe NSISdl can't be called from a function?

Afrow UK 18th April 2006 08:31

There's a few Abort instructions in there.
Abort closes the installer when called from .onInit.
In an install Section it would have cancelled the installation process.

-Stu

Takhir 18th April 2006 10:12

NSISdl may be in function, but not from .onInit. Requires INSTFILES page. Translate option is useless without page as well. InetLoad can do this, but please note - Translate parameters for /popup mode have other values, see readme and samples.

Afrow UK 18th April 2006 11:29

NSISdl will still work outside the InstFiles page, but obviously there will be no dialog.
I would go with Takhir and use the InetLoad plugin.

-Stu

Gridley 18th April 2006 14:13

Thanks guys. I'll check InetLoad.

RE: abort- I did want it to abort install, just that it was reaching those lines when it shouldn't be - as if the NSISdl was being bypassed or causing an abort itself. If InetLoad proves troublesome, I'll try moving the .net check to the first section...

Fretje 18th April 2006 15:31

URL_DOTNET
 
Question: Where do you initialize the "URL_DOTNET" variable which is used to download the file? And how do you adapt it to the language of the system?

thanks!

Gridley 18th April 2006 15:39

I actually haven't gotten that working yet either, but the original method uses the MUI LANGDLL_DISPLAY macro to accomplish that - I would hope to do the same if I can get the english download to work! For now, I've got some of that hard-coded, so that's not where the failure comes from - I should have shown that in the code above...

See: Installing_the_Microsoft_.NET_Framework

Gridley 24th April 2006 13:45

To close this thread, InetLoad is working great. Thanks!


All times are GMT. The time now is 17:31.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.