Checking if the .NET Framework is Installed

JDYoder

Centurion
Joined
Nov 18, 2003
Messages
144
How can I determine on a computer if it has the .NET framework installed? Some registry key?
 
Are you just looking to see? If so you can goto control panel and look at the list in "add/remove programs". It is listed in there
 
Something other than that. We have an installation program that needs to check if the .NET framework is installed on a machine. So I want it to check the registry... or something... whatever it takes.
 
Most programs that I obtain now days includes the bootstrapper so me thinks this is a good idea. I dont know why anybody would try to fake the directory though, im not sure if you uninstall the .net does it leave the directory ? some programs do in that case you would want to use bootstrapper.
 
For now, I'll check for the "%windir%\Microsoft.Net\Framework" directory, which brings me to another question...

What registery setting do I check in order to obtain the windows directory?
 
I'm not trying to push or anything, but you realize that the bootstrapper preforms that check for you, right? You get it all for free. The only way I would not go with the bootstrapper is if I didn't want my program installed if the target machine didn't have the .Net Framework. (With the bootstrapper the .Net Framework will be installed for you if it isn't already installed)

Other than that, if you try and use a .Net installer on a machine that doesn't have the .Net framework installed, it will also preform a check and then tell the user that they need to go to a website (link given) and download the .Net redistributable package.

So if your worries are something other than installation compaitibility concerns, the directory check will do for whatever it is that you are doing.

And %WINDIR% is the environment variable you need to check. Go to a command prompt and hit 'set'. You'll see that variable toward the bottom.
 
mskeel said:
The only way I would not go with the bootstrapper is if I didn't want my program installed if the target machine didn't have the .Net Framework.

This is our scenerio, which is why I'm doing it this way. The long story is we are piggy-backing a very small .NET program onto a large VB6 program and setup that already exists. The .NET program is optional for the user. So I just need to check for the existence of the .NET framework and tell them if they don't have it.

mskeel said:
And %WINDIR% is the environment variable you need to check. Go to a command prompt and hit 'set'. You'll see that variable toward the bottom.

But that's just for my machine. I need this to work on any machine, regardless if they have "C:\Windows", "C:\WINNT", "D:\BobsWindows", etc. So I'm assuming it's a registry call. But no one knows it?
 
JDYoder said:
This is our scenerio, which is why I'm doing it this way. The long story is we are piggy-backing a very small .NET program onto a large VB6 program and setup that already exists. The .NET program is optional for the user. So I just need to check for the existence of the .NET framework and tell them if they don't have it.



But that's just for my machine. I need this to work on any machine, regardless if they have "C:\Windows", "C:\WINNT", "D:\BobsWindows", etc. So I'm assuming it's a registry call. But no one knows it?

I suggest, in the event the .NET Framework is absent, you install it regardless of whether the user chooses to install the .NET application you are piggybacking. At some point or another the .NET Framework will need to be installed anyway so may as well have it over and done with.
 
Last edited:
But I still want to tell them they don't have the .NET framework installed.

So from the answers I'm getting, I assume this is impossible via the registry?
 
Quote:
Originally Posted by mskeel
And %WINDIR% is the environment variable you need to check. Go to a command prompt and hit 'set'. You'll see that variable toward the bottom.

But that's just for my machine. I need this to work on any machine, regardless if they have "C:\Windows", "C:\WINNT", "D:\BobsWindows", etc. So I'm assuming it's a registry call. But no one knows it?
You can find environment settings in the registry, though I am unsure where. And again, you can also check the environement variable directly. In .Net you would do this with a call to Environment.GetEnvironmentVariable(string)
 
%WinDir% is a standard environment variable - you won't need to process the registry to find it.
Just about every programming language / install tool has some method for evaluating these - what tool(s) are you looking at using to discover the existance (or not) of this directory?
 
PlausiblyDamp said:
%WinDir% is a standard environment variable - you won't need to process the registry to find it. Just about every programming language / install tool has some method for evaluating these - what tool(s) are you looking at using to discover the existance (or not) of this directory?


The installation tool is Wise 7.0, which is quite old. It does have a %WIN% variable which has worked in the past, however, on this one machine it returns this value...

C:\DOCUMENT AND SETTINGS\ADMINISTRATOR\WINDOWS\MICROSOFT.NET\FRAMEWORK

Which is very odd to me. Any ideas why that would be? Since Wise 7.0 can access the registry, I thought I'd try that, but I'm open to other suggestions. (Other than upgrading the setup package, which isn't an option at the moment.)





pas30339 said:

Maybe that'll work if I can check for the reg folder...

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\

I'll give that a shot unless anyone has a different idea that would be better.
 
Back
Top