Link to home
Start Free TrialLog in
Avatar of bfuchs
bfuchsFlag for United States of America

asked on

Find out dot net version running

Hi Experts,
Anyone knows of an easy way to determine the .net version running on my pc?
Would prefer a vba function..
Thanks
Avatar of John
John
Flag of Canada image

Start with this and see what is installed.  If installed , it is "running"

http://blogs.msdn.com/b/astebner/archive/2008/10/13/8999004.aspx

All available versions from 2 forward should show up.
Avatar of timgreen7077
timgreen7077

The below link will show you what version of .NET you have installed currently. No downloads are needed for this check. Its found in the registry.

https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed#net_b
Avatar of bfuchs

ASKER

Hi Experts,
@John,
Did not find this download at first page.
the link I followed had many downloads.
Can you post exact link for that tool?

@Timgreen,
I need this to run on each users pc, while regedit is only avail if they're logged as admin.

Thanks,
Ben
This page https://blogs.msdn.microsoft.com/astebner/2008/10/13/net-framework-setup-verification-tool-users-guide/ has a link to the 'new' version that checks up to .NET Framework 4.7.1 .  Although there is a command line to 'run all tests' is listed, it seems like you have select them one at a time.
On the page I posted, under download, get

http://cid-27e6a35d1a492af7.skydrive.live.com/self.aspx/Blog%7C_Tools/netfx%7C_setupverifier%7C_new.zip

I am not sure if this tool runs as non-Admin. It does not ask for UAC OK so it should work on any machine.
>>> Would prefer a vba function..

One method is to list the subfolders in the .Net Framework folder, which are named according to version number.  You can modify this to return only the latest version if you want:
Sub GetDotNetVersions()
    Dim oFolder As Object
    Dim fs As Object
    Dim oSubFolder As Object
    
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set oFolder = fs.getFolder("C:\Windows\Microsoft.NET\Framework")
    
    For Each oSubFolder In oFolder.subfolders
        Debug.Print oSubFolder.Name
    Next
End Sub

Open in new window


Another (more accurate) method is to check registry keys for the various flavors of .net to determine their presence, and the specific version number.   The downside to this approach is that you have to know and update the list with the registry keys for the different versions (I don't think you can do this 'generically' for .Net versions earlier than 4.0).  This code (Sub DotNetVersion) will list the versions... .  

' This calls function GetDotNetVersionInstalled, and lists the versions.
Sub DotNetVersion()
   Dim sKey(7) As String
   Dim i As Integer
   Dim s As String
   
   ' These are the registry keys- update as needed.
   sKey(0) = "HKLM\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}\Version"
   sKey(1) = "HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322"
   sKey(2) = "HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Version"
   sKey(3) = "HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Version"
   sKey(4) = "HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\Version"
   sKey(5) = "HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client\Version"
   sKey(6) = "HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full\Version"
   For i = 0 To 6
       s = GetDotNetVersionInstalled(sKey(i))
       If s <> "" Then Debug.Print sKey(i) & ": " & s
   Next
End Sub

' This uses Windows Scripting to read the registry for exact version for the 
Function GetDotNetVersionInstalled(sKey As String) As String
    GetDotNetVersionInstalled = ""
    Dim WS As Object
    On Error GoTo PROC_ERR
    GetDotNetVersionInstalled = ""
    
    Set WS = CreateObject("WScript.Shell")

    GetDotNetVersionInstalled = WS.RegRead(sKey)
PROC_EXIT:
    Exit Function
PROC_ERR:
    GetDotNetVersionInstalled = "Not Installed"
    Exit Function
End Function

Open in new window


Call it like this:

DotNetVersion

Open in new window

Agree with #a42526889

I would change the first function to only look for folders that start with v
For the second I would include HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node
Avatar of bfuchs

ASKER

Hi Experts,

Basically I need this for a software that requires the following
"3.      Please ensure your computer is running .NET framework 4.5 or higher."
When tried that tool suggested by John/Dave I get all successful up to 4.7.., while when I run the code from mbizup I get either v4.0.30319 or HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client\Version: 4.7.02558
HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full\Version: 4.7.02558
So does that mean I'm not fully setup?

BTW, for installing .net 4.5 is this something I can just download and run?  any side affects?

Thanks,
Ben
Most systems use Programs and Features, Windows Features to install .NET and I have found this best even though it means touching the machines. We set this up at initial installation
Avatar of bfuchs

ASKER

Hi John,
Are you saying that this must be setup at initial installation?
What are my options now?
Thanks,
Ben
SOLUTION
Avatar of John
John
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also look in Programs and Features, Windows Features.  Was .NET ever initialized on any machine?
Avatar of bfuchs

ASKER

Also look in Programs and Features, Windows Features.
I see it there 4.7 (see attached)
So is this the right way to check up?
Thanks,
Ben
Untitled.png
Look in Windows Features (left side of your screen shot) Open Windows Features and see if all .NET are checked.

If they are all checked (enabled). use .NET Framework Setup Verifier to check and verify all versions.
Avatar of bfuchs

ASKER

Under windows features I only see .net 3.5 and nothing is selected. (see attached)
So I'm confused, why do I first saw 4.7 listed?
And what version do I actually have running?
This sounds like a complicate thing to figure out-:(
Why cant it be like any program or operating system that you get to see just by right clicking on my computer icon?!

Thanks,
Ben
Untitled.png
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

What you see for .NET 3.5 is fine...At that point, Windows Updates will look after it and keep it up to date.
So you're saying that if I see .net 3.5 under windows features on windows 7 pc's (which most of our users have), and windows updates are up to date, that means we are good to go with that software mentioned above, which requires .net 4.5 or higher running?

Thanks,
Ben
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

Thanks very much my experts!
You are very welcome and I was happy to help.