- NSIS Discussion
- Installing .NET with dotnetfx.exe
Archive: Installing .NET with dotnetfx.exe
Latem
12th May 2004 15:39 UTC
Installing .NET with dotnetfx.exe
Hello all,
I just got NSIS, so I am very much a newbie. I used HM NIS Editor and its Wizard to make a simple install for an application I am working on. The application is written in VB.NET, and my boss would like me to distribute the framework, and install it if needed, with the installer for the application. I have a few questions regarding this issue.
I found the nifty little function to detect .NET framework in the Documentation (and in the archives), and I got it to work with my script. I also read in the forums that you should place this in the on.Init function, or something like that. I didnt fully understand that. Right now this is what I do:
Section"GLS" SEC01
Call IsDotNETInstalled
Pop $R3
StrCmp $R3 0+3
Goto+2
; else
MessageBox MB_OK "Can't find .NET!"
...
And as you can see this code is at the start of my main "section". My first question is if putting that in onInit is more correct how do I do that? Do I go Function SEC01.onInit or something like that, and place the code there. And then where/how do I call the function?
My second question is how do I get the installer to install the .NET Framework. So, how do I package dotnetfx.exe into my installer, and then how do I get it to run that file (instead of the MessageBox part). I couldn't find an example of this anywhere.
I am kinda under time pressure, so I havent looked at the docs in great detail, so Im not familiar with much yet. That's also why I am asking for help. Sorry if this is supposed to be "common" knowledge or something, and I am asking how to do it.
Aside, from my little experince with NSIS, it seems like its a pretty cool system. And definitly different from MS Visual Studio Installer tool.
Thanks in advance,
Latem
Davion
13th May 2004 10:09 UTC
Welcome to the forums Latem
onInit isn't a section, it's a function which is called right after starting the exe so you should define your onInit function like below on the very first beginning of your script
Function .onInit
Call IsDotNETInstalled
Pop $R3
StrCmp $R3 0 +3
Goto +2
; else
MessageBox MB_OK "Can't find .NET!"
...
FunctionEnd
to install .NET framework you should use ExecWait, cause it waits until the called application finished, alternative you can call it after your last dialog to install if necessary
ExecWait:
ExecWait '"C:\path\framework.exe" (/parameters)'
first you write the path of the file you wanna use,
and after this you set parameters you maybe need
(You can find more Examples in NSIS\Examples\ as the name says)
hope this helps
greets Davion
zimsms
13th May 2004 13:44 UTC
Just a side note:
You should also be careful to install the .NET Framework that matches the INSTALLED locale version of the Operating System. You should obtain the framework from the appropriate link. I have listed a few of these below. If you do not adhere to this, you could make your clients system unstable.
; .NET Framework
;English
!define URL_DOTNET_1033 "http://download.microsoft.com/download/a/a/c/aac39226-8825-44ce-90e3-bf8203e74006/dotnetfx.exe"
;German
!define URL_DOTNET_1031 "http://download.microsoft.com/download/4/f/3/4f3ac857-e063-45d0-9835-83894f20e808/dotnetfx.exe"
;Spanish
!define URL_DOTNET_1034 "http://download.microsoft.com/download/8/f/0/8f023ff4-2dc1-4f10-9618-333f5b9f8040/dotnetfx.exe"
;French
!define URL_DOTNET_1036 "http://download.microsoft.com/download/e/d/a/eda9d4ea-8ec9-4431-8efa-75391fb91421/dotnetfx.exe"
;Portuguese (Brazil)
!define URL_DOTNET_1046 "http://download.microsoft.com/download/8/c/f/8cf55d0c-235e-4062-933c-64ffdf7e7043/dotnetfx.exe"
;Chinese (Simplified)
!define URL_DOTNET_2052 "http://download.microsoft.com/download/7/b/9/7b90644d-1af0-42b9-b76d-a2770319a568/dotnetfx.exe"
See the Microsoft Download page for the framework, select the disered language and view the source and scan it for the download link if you need a language that I have not provided above.
Cheers,
ZIMSMS
Latem
14th May 2004 13:42 UTC
Thanks for the feedback.
This is my .onInit function:
onInit
; check for .NET
Call IsDotNETInstalled
Pop $R3
StrCmp $R3 0 not_found found
found:
goto end
not_found:
MessageBox MB_OKCANCEL "GLS has detected that you do not have Microsoft .NET Framework Installed.\r\n Press OK to install .NET Framework."
pop $R0
StrCmp $R0 IDOK installNET
Abort
installNET:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "dotnetfx.exe"
ExecWait '"$INSTDIR\dotnetfx.exe"'
end:
>FunctionEnd
>
When I run my installer on a computer w/o .NET, it detects that it's not there properly. Then the msg box comes up, but when I press "OK" nothing seems to happen. It did not start the .NET install. What am I doing wrong?
thanks,
Latem
zimsms
14th May 2004 14:23 UTC
Try the following:
onInit
; check for .NET
Call IsDotNETInstalled
Pop $R3
StrCmp $R3 0 not_found found
found:
goto end
not_found:
MessageBox MB_OKCANCEL "GLS has detected that you do not have Microsoft .NET Framework Installed.\r\n Press OK to install .NET Framework." IDOK installNET IDCANCEL 0
Abort
installNET:
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "dotnetfx.exe"
ExecWait '"$INSTDIRdotnetfx.exe"'
end:
>FunctionEnd
>
Latem
14th May 2004 15:25 UTC
that worked.
thank you.
Latem
zimsms
14th May 2004 15:44 UTC
I have contributed an example of installing the .Net Framework, feel free to take a look at it at the following location.
Installing the Microsoft .Net Framework (Multi Language Example)
mattdisaster
28th May 2004 05:01 UTC
I don't mean to steal your thread, or be a complete noob - but I have been fooling around with the same thing and haven't been able to get it working. For some reason or another nothing happens once the script gets compiled, it just doesnt execute, any ideas? Thanks in advance.
-matt
zimsms
28th May 2004 13:39 UTC
Matt,
I have attached a modified version of your script that will give you the functionality you asked for, However, I strongly advise that you read my Archive document (Follow the link above), to see how this should be done properly in a multi lingual install.
BTW: You had it in an endless loop, and were never actually checking the registry to see if .Net was installed.
Cheers,
ZIMSMS
mattdisaster
28th May 2004 13:47 UTC
Thanks alot! I was actually trying to edit or remove my post when you were posting your reply! I'll blame that one on me being just completely out of whack. I restarted/organized my script and I'm gonna take it one step at a time. I'm now looking more indepth to your documentation and getting overwhelmed already, but I will endure. heh Thanks again for the help!
-matt
zimsms
28th May 2004 14:05 UTC
If you need help, let me know. I made a really nice Multilingual Example, but unfortunately, I set it up with a real world build environment set up for locale branding and everything, very flexible. Unfortunately, doing all that made it a little bit too big to post on the archive or in a thread.
mattdisaster
28th May 2004 14:51 UTC
Alittle help would be great! If you want to send it to me, that would be fine, mattnorman82@snet.net shoudl be able to take it, just something to give me a heads up on how it should be set up, I've come to terms with me being a total newb. lol. Thanks again for everything!
-matt
ps- I'm also idling in the chat room under the handle Disaster
Fretje
15th November 2005 15:01 UTC
How to obtain right language
I think I'm not getting this right...
The dotnetfx.exe you install has to be the same language as the os you are installing it on right?
But like I interpret your code, you let the user select a language... What if that isn't the right one?
Isn't there a way to determine the OS language and not let the user select it?
TIA,
Fretje
zimsms
15th November 2005 23:28 UTC
Hello Fretje,
Actually, It does interpret the OS you are running on, and installs the appropriate dotnet executable no matter what language you choose to install the application in.
Cheers,
zimsms
JCD29
15th November 2005 23:47 UTC
Just to know how to get if the .net dotnetfx.exe has already been installed.
To test if the registry key exists : Software\Microsoft\.NETFramework
thanks by advance.
Fretje
16th November 2005 08:03 UTC
Hello zimsms,
Can you please shed some light on this please, because I realy don't see it.
What I see in your .OnInit function is the following line:
StrCpy $URL_DOTNET "${URL_DOTNET_1033}"
But that's the only place where $URL_DOTNET is assigned and this looks quite "hard coded" to me...
Or am I missing something?
Where is the logic which determines the os language, and assigns the $URL_DOTNET accordingly?
Greetings,
Fretje
Fretje
16th November 2005 16:16 UTC
Other people than zimsms may answer as well ;-)
Or am I not the only one who isn't seeing it?
Greetz,
Fretje
JCD29
17th November 2005 10:51 UTC
Just to know how to get if the .net dotnetfx.exe has already been installed.
To test if the registry key exists : Software\Microsoft\.NETFramework
thanks by advance.
zimsms
17th November 2005 17:52 UTC
Fretje,
There used to be a complete example in the archive, but they've changed so much on this site, that I can't find it. I went and looked at my post, the one you are asking about. It looks like a piece of it may be missing. I noticed some of my files had been altered as well.
I currently don't have the code on this machine. But, I can tell you the code you are looking for was in an override of the .GUIInit function, which I had called MyGUIINit. Basically you check in this override for the variable you populated in the .oninit ($OSLANGUAGE) then StrCpy the appropriate URL into the URL_DOTNET variable. The initial assignment you are seeing is just a default initialization.
I will see if I can find a copy of my old example, and post the block in the thread. Finding it, may take a while, and I won't be able to post it until 8pm EST. (Currently (1pm EST).
Cheers,
ZIMSMS
zimsms
17th November 2005 17:54 UTC
JCD29,
Check out the Get .Net Version function.
Cheers,
ZIMSMS
Fretje
18th November 2005 09:46 UTC
hello zimsms,
I'm looking forward to receiving the right code...
Thanks a lot already!
Fretje
kichik
20th November 2005 18:50 UTC
Originally posted by zimsms
There used to be a complete example in the archive, but they've changed so much on this site, that I can't find it.
All of the old Archive links should still work. If they don't, please let me know.
JCD29
21st November 2005 22:32 UTC
thanks zimsms
for your help.. i discover the link
Fretje
22nd November 2005 07:49 UTC
Still waiting for the code...
or some more insight into retrieving the OS language...
tnx,
Fretje
zimsms
22nd November 2005 23:57 UTC
Fretje,
I sent you a private message a few days ago.....
Cheers,
ZIMSMS
Fretje
23rd November 2005 12:34 UTC
Zimsms,
I didn't even know I could receive private messages ;-)
But I have seen it now and replied to it...
Greetings,
Fretje
JCD29
31st January 2006 17:42 UTC
where is described IsDotNETInstalled ?
this method is provided with NSIS examples ?