检测是否已安装 .NET Framework 3.5的js脚本

2019-12-25,,,,,

本主题提供一个以 HTML/JavaScript 编写的脚本,管理员可以使用该脚本来确定系统上是否存在 .NET Framework 3.5。
复制代码 代码如下:
<HTML>
<HEAD>
<TITLE>Test for the .NET Framework 3.5</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
<SCRIPT LANGUAGE="JavaScript">
<!--
var dotNETRuntimeVersion = "3.5.0.0";

function window::onload()
{
if (HasRuntimeVersion(dotNETRuntimeVersion))
{
result.innerText =
"This machine has the correct version of the .NET Framework 3.5."
}
else
{
result.innerText =
"This machine does not have the correct version of the .NET Framework 3.5." +
" The required version is v" + dotNETRuntimeVersion + ".";
}
result.innerText += "\n\nThis machine's userAgent string is: " +
navigator.userAgent + ".";
}

//
// Retrieve the version from the user agent string and
// compare with the specified version.
//
function HasRuntimeVersion(versionToCheck)
{
var userAgentString =
navigator.userAgent.match(/.NET CLR [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 2 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>
<div id="result" />
</BODY>
</HTML>

如果搜索“.NET CLR”版本成功,将显示以下类型的状态消息:
This machine has the correct version of the .NET Framework 3.5.
This machine's userAgent string is: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 3.0.590; .NET CLR 3.5.20726; MS-RTC LM 8).
否则,显示以下类型的状态消息:
This machine does not have the correct version of the .NET Framework 3.5. The required version is v3.5.0.0.
This machine's userAgent string is: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 3.0.590; MS-RTC LM 8).

您可能感兴趣的文章:

  • Microsfot .NET Framework4.0框架 安装失败的解决方法
  • Sql server 2005安装时ASP.Net版本注册要求警告的解决方法
  • IIS6 安装与配置.net 2.0过程的详细图解
  • Win2008 R2安装.NET Framework 4的windows6.1-KB958488-V6001-x64出现灾难性故障解决方法
  • IIS和.net framework 4.0的安装顺序导致的问题(重新注册.net 4.0)
  • asp.net Ajax 安装与卸载方法
  • Visual Studio 2015和 .NET Core安装教程
  • IIS和.NET(1.1/2.0)的安装顺序及错误解决方法
  • ASP.NET Sql Server安装向导(aspnet_regsql.exe)错误解决一例
  • Windows Server 2012 R2 或 2016无法安装.Net 3.5.1

《检测是否已安装 .NET Framework 3.5的js脚本.doc》

下载本文的Word格式文档,以方便收藏与打印。