TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
Determine what version of .NET is installed
Monday, January 19, 2009 8:48 AM
( permalink)
A couple years ago mbouchard posted a method to determine what version of .NET is installed on your system: http://www.visualbasicscript.com/m_35340/mpage_1/tm.htm#35340 I figured I'd take a crack at it with a different approach. What do you think?
Function NETVer()
Dim d : Set d = CreateObject("htmlfile")
Dim Matches,Match
Dim Result : Result = Array()
Dim RE : Set RE = New RegExp
RE.Pattern = "\.NET CLR ([\d\.]+)"
RE.Global = True
Set Matches = RE.Execute(d.parentWindow.navigator.userAgent)
For Each Match In Matches
ReDim Preserve Result(UBound(Result) + 1)
Result(UBound(Result)) = Match.SubMatches(0)
Next
NETVer = Result
End Function
MsgBox Join(NETVer(),",")
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
ehvbs
-
Total Posts
:
3320
- Scores: 112
-
Reward points
:
0
- Joined: 6/22/2005
- Location: Germany
-
Status: offline
|
RE: Determine what version of .NET is installed
Monday, January 19, 2009 9:13 AM
( permalink)
Hi TNO, really nice. I wish I'd had this excellent idea! So I can only show my slightly different implementation:
Function NETVer()
Dim RE : Set RE = New RegExp
RE.Pattern = "\.NET CLR ([\d.]+)"
RE.Global = True
Dim Matches : Set Matches = RE.Execute( _
CreateObject( "htmlfile" ).parentWindow.navigator.userAgent _
)
ReDim aRVal( Matches.Count - 1 )
Dim nIdx
For nIdx = 0 To UBound( aRVal )
aRVal( nIdx ) = Matches( nIdx ).SubMatches( 0 )
Next
NETVer = aRVal
End Function
Regards ehvbs
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
RE: Determine what version of .NET is installed
Monday, January 19, 2009 9:15 AM
( permalink)
Shorter is better, no complaints here.
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
RE: Determine what version of .NET is installed
Monday, January 19, 2009 9:32 AM
( permalink)
Here's a JScript version if anyone is interested:
var NetVer = (new ActiveXObject("htmlfile")).parentWindow
.navigator.userAgent.match(/\.NET CLR ([\d\.]+)/g).join(",")
.replace(/\.NET CLR/g,"").split(",")
line breaks optional
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
mbouchard
-
Total Posts
:
2110
- Scores: 29
-
Reward points
:
0
- Joined: 5/15/2003
- Location: USA
-
Status: offline
|
RE: Determine what version of .NET is installed
Friday, January 23, 2009 6:38 AM
( permalink)
Does this give you the full version, including SP level or just the major version? For instance, the script says that, for version 2.0 I have 2.0.50727 the registry on my pc shows 2.0.50727.1434 is installed. Looking at the list found here 2.0.50727.1434 is 2.0 SP1. Just wondering if there is a way using your method to get the full version.
Mike For useful Scripting links see the Read Me First stickey! Always remember Search is your friend.
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
RE: Determine what version of .NET is installed
Friday, January 23, 2009 12:04 PM
( permalink)
Afraid not, But another alternative is looking here: HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
iburnell
-
Total Posts
:
43
- Scores: 0
-
Reward points
:
0
- Joined: 6/2/2009
-
Status: offline
|
RE: Determine what version of .NET is installed
Wednesday, February 09, 2011 11:47 PM
( permalink)
Hi TNO - Thanks for posting this script I need to determine the highest version of Framework on the machine - Is there a simple way to pick out the array with the highest value? I tried using Topnumber = UBound(NETVer()) and this returns correctly the array number in my case 2 with the highest value but I wanted to get the actual version number contained in array 2
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
RE: Determine what version of .NET is installed
Thursday, February 10, 2011 3:22 AM
( permalink)
Here is a slightly different version where an ArrayList is sorted in descending order before it is returned: Function NETVer()
Dim RE : Set RE = New RegExp
RE.Pattern = "\.NET CLR ([\d.]+)"
RE.Global = True
Dim Matches : Set Matches = RE.Execute( _
CreateObject( "htmlfile" ).parentWindow.navigator.userAgent _
)
Dim Result : Set Result = CreateObject("System.Collections.ArrayList")
Dim Match
For Each Match In Matches
Result.Add Match.SubMatches(0)
Next
Result.Sort
Result.Reverse
Set NETVer = Result
End Function MsgBox NETVer()(0)
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
iburnell
-
Total Posts
:
43
- Scores: 0
-
Reward points
:
0
- Joined: 6/2/2009
-
Status: offline
|
RE: Determine what version of .NET is installed
Friday, February 11, 2011 1:32 AM
( permalink)
Thanks - this works great
|
|
|
|