-1

Following code checks if Microsoft Excel is installed into your computer.

    Dim officeType1 As Type = Type.GetTypeFromProgID("Excel.Application")
    If officeType1 Is Nothing Then
        MessageBox.Show("Microsoft Excel is not installed!")
    End If

Question: I need a code which checks if "Microsoft .Net Framework 4" is installed or not?

Herry Markowitz
  • 208
  • 3
  • 15
  • http://stackoverflow.com/q/199080/62576 is one of the many already existing posts about detecting the presence of a .NET version. Did you spend any time researching this topic before posting your question? – Ken White Dec 19 '15 at 03:29
  • @Thanks Ken White, but that source very complicated for me... – Herry Markowitz Dec 19 '15 at 04:19
  • There are other posts that have other source. My point is that you apparently did zero research before posting here, including failing to do a basic search (or even look at the suggested list of duplicates that were shown as you typed your question, and that are now in the list of related questions to the right of your post below the job ads). We expect you to make at least a minimal effort to find a solution yourself before posting here. – Ken White Dec 19 '15 at 04:21
  • 1
    VB.Net runs inside the .Net framework. If your check code is executing, it's installed. – Joel Coehoorn Dec 19 '15 at 04:29

1 Answers1

-1

As mentioned in one of the comments, there are plenty of other references. A quick search would yield many different ways to check for a .NET version.

You could check for a registry key, but A very simple way could just be looking for a directory such as:

C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
C:\WINDOWS\Microsoft.NET\Framework\v3.0
C:\WINDOWS\Microsoft.NET\Framework\v3.5
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319

So you'd be looking at something like this

If My.Computer.FileSystem.DirectoryExists("C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319") Then
  'do something
End If
Rickybobby
  • 245
  • 1
  • 13
  • @ beatles1235, Thanks for answer. But are you sure existing of C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319 file means it is installed? Because I have C:\WINDOWS\Microsoft.NET\Framework\v3.5 file but it isnt installed! – Herry Markowitz Dec 19 '15 at 04:00