Checking if the .NET Framework is Installed

JDYoder

Well-known member
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, Ill 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?
 
Im 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 didnt want my program installed if the target machine didnt have the .Net Framework. (With the bootstrapper the .Net Framework will be installed for you if it isnt already installed)

Other than that, if you try and use a .Net installer on a machine that doesnt 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. Youll see that variable toward the bottom.
 
mskeel said:
The only way I would not go with the bootstrapper is if I didnt want my program installed if the target machine didnt have the .Net Framework.

This is our scenerio, which is why Im 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 dont have it.

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

But thats just for my machine. I need this to work on any machine, regardless if they have "C:\Windows", "C:\WINNT", "D:\BobsWindows", etc. So Im assuming its a registry call. But no one knows it?
 
JDYoder said:
This is our scenerio, which is why Im 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 dont have it.



But thats just for my machine. I need this to work on any machine, regardless if they have "C:\Windows", "C:\WINNT", "D:\BobsWindows", etc. So Im assuming its 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 by a moderator:
But I still want to tell them they dont have the .NET framework installed.

So from the answers Im 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. Youll see that variable toward the bottom.

But thats just for my machine. I need this to work on any machine, regardless if they have "C:\Windows", "C:\WINNT", "D:\BobsWindows", etc. So Im assuming its 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 wont 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 wont 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 Id try that, but Im open to other suggestions. (Other than upgrading the setup package, which isnt an option at the moment.)





pas30339 said:

Maybe thatll work if I can check for the reg folder...

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\

Ill give that a shot unless anyone has a different idea that would be better.
 
Back
Top