0

I'm using InstallShield 2009 and have to launch an executable when I click the 'Finish' button of the installation wizard.

So, to do this, I used custom action and it's working fine, but now, I have to make a verification before call this custom action. I have to verify if the .Net framework is installed, if true, don't execute if isn't installed execute.

Can anybody help?

Please let me know if anything isn't clear.

Thanks.

Leonardo Arruda
  • 241
  • 1
  • 6
  • 14
  • I forgot to tell that the .net version that I'm looking for is 4.0 – Leonardo Arruda Mar 16 '12 at 13:17
  • Leonardo, you keep asking the same question over and over but you are asking the wrong questions. We can't help you do things the wrong way. – Christopher Painter Mar 16 '12 at 13:28
  • 1
    I can't help with InstallShield, so I don't post this as an answer, however I suppose you have same form of reading values in the registry. This path contains the info you require: `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full`. The key to read is `Install`, if you get 1 then you have NET Frameword istalled. Keep in mind that if on target machine there is the _Client Profile_ installed you should check for `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client`. See [Microsoft Support](http://support.microsoft.com/kb/318785) – Steve Mar 16 '12 at 13:31
  • But, add a search for this key is what I don't know. I need to make a function to return true or false if this key exits. But I don't know how to make it in InstallShield. – Leonardo Arruda Mar 16 '12 at 13:34

3 Answers3

1

It seems like you want to install the FW if not present: Why don't you use a prerequisite?
See e.g. HERE for another question on that topic.

Community
  • 1
  • 1
Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
0

You should be able to bundle the .NET redistributable with the installer, and execute it via an invocation of LaunchApp or LaunchApplication.

As a comment on someone else's answer, you can use the RegDBKeyExist function to read the registry and see if .NET is already installed.

For the registry keys, you might want to set this option:

REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY;

This makes the registry search use the Wow64 registry redirection on 64-bit machines. That might be an issue.

Also, I think the default registry root is HKEY_CURRENT_USER. If you want to change it to, say, HKEY_LOCAL_MACHINE, you can do so by calling:

RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);

ashes999
  • 9,925
  • 16
  • 73
  • 124
  • Could you give an example of how to use this RegDBKeyExist function? Thanks – Leonardo Arruda Mar 16 '12 at 14:54
  • I mean, could I use it only on script? Or can I put it like a DoAction event condition in a button? – Leonardo Arruda Mar 16 '12 at 14:56
  • Actually, didn't work. :( Even with the .net framework installed the RegDBKeyExist method only returns -1. What could it be? – Leonardo Arruda Mar 16 '12 at 17:07
  • You probably need to set `REGDB_OPTIONS` and call `RegDBSetDefaultRoot` first. I'll update my answer. – ashes999 Mar 16 '12 at 18:52
  • Why would you use an InstallScript custom action to read the registry when you could just use the RegLocator / AppSearch tables? Reinventing the wheel is not a Windows Installer best practice. – Christopher Painter Mar 16 '12 at 22:19
  • 1
    @ChristopherPainter thanks for the DV. This is the only solution that worked for me, so it's the solution I'm posting. – ashes999 Mar 17 '12 at 03:26
  • @ashes999, can you put a complete example of how to make this search. Maybe I'm missing something. Thanks. – Leonardo Arruda Mar 19 '12 at 12:48
  • @LeonardoArruda please uncheck my answer as the accepted answer then. Sorry, I don't have any code I can share. – ashes999 Mar 19 '12 at 13:54
  • @ashes999, see this question please: http://stackoverflow.com/questions/9770848/regdbkeyexists-always-incorrectly-returns-1 – Leonardo Arruda Mar 19 '12 at 14:04
  • Worked! I was using a wrong path, this one must be HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full and I was using HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Install, this 'Install' at the end must not be there. Was my mistake, your answer is right! Thanks. – Leonardo Arruda Mar 20 '12 at 11:41
0

Why don't you just check for this file:

%systemroot%\Microsoft.NET\Framework\v4.0.30319\System.Core.dll

It's guaranteed to be there if the framework v4 is installed.

Jimmy D
  • 5,282
  • 16
  • 54
  • 70
  • The official way that MS recommends is to look for the registry keys, not (random) DLLs. – ashes999 Mar 16 '12 at 20:29
  • The official way is to use AppSearch not InstallScript registry functions. – Christopher Painter Mar 16 '12 at 22:20
  • Why use either when you can use MsiNetAssemblySupport? http://msdn.microsoft.com/en-us/library/windows/desktop/aa370325.aspx – Michael Urman Mar 17 '12 at 01:04
  • Framework v4 is plural not singular. That property wouldn't be able to distinguish between .NET 4.0 client and full profile installations. The real problem here though is that OP want's to use a custom action launched from the SetupComplete dialog to read the registry to see if .NET is installed, ask the user if they would like to install it and then use LaunchAppAndWait to install it because he refuses to use Setup Prereqs because his boss tells him he wants it done this way. – Christopher Painter Mar 17 '12 at 12:06
  • Finally you understood that must be this way @ChristopherPainter!! Now, Why don't you just teach me how to do this? I will be grateful! – Leonardo Arruda Mar 19 '12 at 11:46
  • 1
    No, I will not encourage failure. http://robmensching.com/blog/posts/2007/8/17/Zataoca-Custom-actions-are-generally-an-admission-of-failure – Christopher Painter Mar 19 '12 at 12:32