You can check whether. NET Framework 3.5 is installed by reading the registry key or querying the user proxy string in Internet Explorer.
Read registry key
Install. NET Framework 3.5ProgramThe registry key is written. You can check whether. NET Framework 3.5 is installed by checking the registry items listed in the following table.
Registry name |
Value |
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Net Framework Setup \ NDP \ v3.5 |
Name: Install Type: DWORD Data: 1 |
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Internet Settings \ 5.0 \ User Agent \ post platform |
Name: Version Type: REG_SZ Data:. Net CLR 3.5.build number |
Read the user proxy string in the browser
After. NET Framework 3.5 is installed on the computer,. NET Framework 3.5 is displayed as part of the user proxy string reported in the browser header. The following example demonstrates an Example page that uses JavaScript to detect and report whether. NET Framework 3.5 is installed.
< Html > < Head > < Title > Test for. NET Framework 3.5 </ Title > < Meta HTTP-EQUIV = "Content-Type" Content = "Text/html; charsets = UTF-8" /> < Script Type = "Text/JavaScript" > <! -- VaR Netfx3runtimeversion = "3.5.21022" ; Function Body_onload (){ VaR Result = Document. getelementbyid ( "Result" ); If (Hasruntimeversion (netfx3runtimeversion) {result. innerhtml ="This machine has the correct version of the. NET Framework 3.5 runtime :" + Netfx3runtimeversion + "." + "\ N \ nthis machine's useragent string is :" + Navigator. useragent + "." ;} Else {Result. innerhtml = "The. NET Framework Version 3.5 is not installed on this computer. <br/>" + "Click <a href = 'HTTP: // msdn.microsoft.com/windowsvista/default.aspx'>" + "Here </a> to get the. NET Framework 3.5 now ." ;}} // // Retrieve the version from the user agent string and compare with specified version. // Function Hasruntimeversion (versiontocheck ){ VaR Useragentstring = navigator. useragent. Match (/. Net CLR 3.5. [0-9] +/G ); If (Useragentstring! = Null ){ VaR I; For (I = 0; I <useragentstring. length; ++ I ){ If (Compareversions (getversion (versiontocheck), getversion (useragentstring [I]) <= 0) Return True ;}} Return False ;} // // Extract the numeric part of the version string. // Function Getversion (versionstring ){ VaR Numericstring = versionstring. Match (/([0-9] +) \. ([0-9] +) \. ([0-9] +)/I ); Return Numericstring. Slice (1 );} // // Compare the version strings by converting them to numeric format. // Function Compareversions (Version1, version2 ){ For (I = 0; I <version1.length; ++ I ){ VaR Number1 =New Number (Version1 [I]); VaR Number2 = New Number (version2 [I]); If (Number1 <number2) Return -1; If (Number1> number2) Return 1 ;} Return 0;} --> </ Script > </ Head > < Body Onload = "Body_onload ();" > < Div ID = "Result" > </ Div > </ Body > </ Html >
If the search string ". NET Framework 3.5" is successful, the following message is displayed:
This machine has the correct version of the. NET Framework 3.5: 3.5.28015.00.
This machine's useragent string is: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; sv1;. Net CLR 1.1.4322;. Net CLR 2.0.50727;. Net CLR 3.5.28015.00 ).
(According to the different browser and browser versions used to test the. NET Framework, the detailed information of the user proxy string is slightly different .)
If ". NET Framework 3.5" is not installed, the following message is displayed:
The. NET Framework Version 3.5 is not installed on this computer.
Click here to get the. NET Framework 3.5 now.