这里也提出了类似的问题,但这是针对。net 3.5的。具体来说,我正在寻找以下:
确定安装了哪些.NET Framework版本和服务包的正确方法是什么? 是否有可以使用的注册表项列表? 框架版本之间是否存在依赖关系?
这里也提出了类似的问题,但这是针对。net 3.5的。具体来说,我正在寻找以下:
确定安装了哪些.NET Framework版本和服务包的正确方法是什么? 是否有可以使用的注册表项列表? 框架版本之间是否存在依赖关系?
当前回答
注册表是检测是否安装了特定版本的框架的官方方法。
需要更改哪些注册表项取决于您正在寻找的框架版本:
Framework Version Registry Key ------------------------------------------------------------------------------------------ 1.0 HKLM\Software\Microsoft\.NETFramework\Policy\v1.0\3705 1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322\Install 2.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Install 3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\InstallSuccess 3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\Install 4.0 Client Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client\Install 4.0 Full Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full\Install
一般来说,你在寻找:
"Install"=dword:00000001
除了。net 1.0,它的值是一个字符串(REG_SZ)而不是一个数字(REG_DWORD)。
确定服务包级别遵循类似的模式:
Framework Version Registry Key ------------------------------------------------------------------------------------------ 1.0 HKLM\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}\Version 1.0[1] HKLM\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}\Version 1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322\SP 2.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\SP 3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\SP 3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\SP 4.0 Client Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client\Servicing 4.0 Full Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full\Servicing [1] Windows Media Center or Windows XP Tablet Edition
如你所见,如果你在Windows Media Center或Windows XP Tablet Edition上运行,. net 1.0的SP级别会发生变化。同样,. net 1.0使用字符串值,而其他所有的都使用DWORD。
对于。net 1.0,这些键的字符串值的格式为#,#,####,#。最后一个#是Service Pack级别。
虽然我没有明确要求,如果你想知道框架的确切版本号,你可以使用这些注册表项:
Framework Version Registry Key ------------------------------------------------------------------------------------------ 1.0 HKLM\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}\Version 1.0[1] HKLM\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}\Version 1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322 2.0[2] HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Version 2.0[3] HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Increment 3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Version 3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\Version 4.0 Client Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Version 4.0 Full Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Version [1] Windows Media Center or Windows XP Tablet Edition [2] .NET 2.0 SP1 [3] .NET 2.0 Original Release (RTM)
同样,. net 1.0使用字符串值,而其他所有的都使用DWORD。
额外的笔记
for .NET 1.0 the string value at either of these keys has a format of #,#,####,#. The #,#,#### portion of the string is the Framework version. for .NET 1.1, we use the name of the registry key itself, which represents the version number. Finally, if you look at dependencies, .NET 3.0 adds additional functionality to .NET 2.0 so both .NET 2.0 and .NET 3.0 must both evaulate as being installed to correctly say that .NET 3.0 is installed. Likewise, .NET 3.5 adds additional functionality to .NET 2.0 and .NET 3.0, so .NET 2.0, .NET 3.0, and .NET 3. should all evaluate to being installed to correctly say that .NET 3.5 is installed. .NET 4.0 installs a new version of the CLR (CLR version 4.0) which can run side-by-side with CLR 2.0.
针对.NET 4.5的更新
如果安装了。net 4.5,那么注册表中将没有v4.5键。相反,你必须检查HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full键是否包含一个名为Release的值。如果存在这个值,则表示安装了。net 4.5,否则没有。更多细节可以在这里和这里找到。
其他回答
我需要找出我电脑上的。net框架的版本,我所做的就是打开控制面板,选择“卸载程序”选项。之后,我把程序按名称分类,找到了Microsoft . net Framework 4客户端配置文件。
下面是一个PowerShell脚本,用于获取已安装的。net框架版本
function Get-KeyPropertyValue($key, $property)
{
if($key.Property -contains $property)
{
Get-ItemProperty $key.PSPath -name $property | select -expand $property
}
}
function Get-VersionName($key)
{
$name = Get-KeyPropertyValue $key Version
$sp = Get-KeyPropertyValue $key SP
$install = Get-KeyPropertyValue $key Install
if($sp)
{
"$($_.PSChildName) $name SP $sp"
}
else{
"$($_.PSChildName) $name"
}
}
function Get-FrameworkVersion{
dir "hklm:\SOFTWARE\Microsoft\NET Framework Setup\NDP\" |? {$_.PSChildName -like "v*"} |%{
if( $_.Property -contains "Version")
{
Get-VersionName $_
}
else{
$parent = $_
Get-ChildItem $_.PSPath |%{
$versionName = Get-VersionName $_
"$($parent.PSChildName) $versionName"
}
}
}
}
$v4Directory = "hklm:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
if(Test-Path $v4Directory)
{
$v4 = Get-Item $v4Directory
$version = Get-KeyPropertyValue $v4 Release
switch($version){
378389 {".NET Framework 4.5"; break;}
378675 {".NET Framework 4.5.1 installed with Windows 8.1 or Windows Server 2012 R2"; break;}
378758 {".NET Framework 4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2"; break;}
379893 {".NET Framework 4.5.2"; break;}
{ 393295, 393297 -contains $_} {".NET Framework 4.6"; break;}
{ 394254, 394271 -contains $_} {".NET Framework 4.6.1"; break;}
{ 394802, 394806 -contains $_} {".NET Framework 4.6.2"; break; }
}
}
它是根据如何:确定安装哪个. net框架版本编写的。请使用get - frameworkversion()函数获取有关已安装的. net框架版本的信息。
列举HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP的子键。每个子键都是一个。net版本。如果它存在于机器上,则它应该具有Install=1值,如果使用MSI安装,则它应该具有显示服务包的SP值和MSI=1值。(.例如,Windows Vista上的NET 2.0没有最后一个,因为它是操作系统的一部分。)
请参阅如何:确定安装的. net框架版本(MSDN)。
MSDN提出了一个函数示例,它似乎完成了版本1-4的工作。根据文章,该方法输出为:
v2.0.50727 2.0.50727.4016 SP2
v3.0 3.0.30729.4037 SP2
v3.5 3.5.30729.01 SP1
v4
Client 4.0.30319
Full 4.0.30319
注意,对于“4.5及更高版本”,还有另一个函数。
注册表是检测是否安装了特定版本的框架的官方方法。
需要更改哪些注册表项取决于您正在寻找的框架版本:
Framework Version Registry Key ------------------------------------------------------------------------------------------ 1.0 HKLM\Software\Microsoft\.NETFramework\Policy\v1.0\3705 1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322\Install 2.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Install 3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\InstallSuccess 3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\Install 4.0 Client Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client\Install 4.0 Full Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full\Install
一般来说,你在寻找:
"Install"=dword:00000001
除了。net 1.0,它的值是一个字符串(REG_SZ)而不是一个数字(REG_DWORD)。
确定服务包级别遵循类似的模式:
Framework Version Registry Key ------------------------------------------------------------------------------------------ 1.0 HKLM\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}\Version 1.0[1] HKLM\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}\Version 1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322\SP 2.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\SP 3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\SP 3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\SP 4.0 Client Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Client\Servicing 4.0 Full Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full\Servicing [1] Windows Media Center or Windows XP Tablet Edition
如你所见,如果你在Windows Media Center或Windows XP Tablet Edition上运行,. net 1.0的SP级别会发生变化。同样,. net 1.0使用字符串值,而其他所有的都使用DWORD。
对于。net 1.0,这些键的字符串值的格式为#,#,####,#。最后一个#是Service Pack级别。
虽然我没有明确要求,如果你想知道框架的确切版本号,你可以使用这些注册表项:
Framework Version Registry Key ------------------------------------------------------------------------------------------ 1.0 HKLM\Software\Microsoft\Active Setup\Installed Components\{78705f0d-e8db-4b2d-8193-982bdda15ecd}\Version 1.0[1] HKLM\Software\Microsoft\Active Setup\Installed Components\{FDC11A6F-17D1-48f9-9EA3-9051954BAA24}\Version 1.1 HKLM\Software\Microsoft\NET Framework Setup\NDP\v1.1.4322 2.0[2] HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Version 2.0[3] HKLM\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727\Increment 3.0 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Version 3.5 HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5\Version 4.0 Client Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Version 4.0 Full Profile HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Version [1] Windows Media Center or Windows XP Tablet Edition [2] .NET 2.0 SP1 [3] .NET 2.0 Original Release (RTM)
同样,. net 1.0使用字符串值,而其他所有的都使用DWORD。
额外的笔记
for .NET 1.0 the string value at either of these keys has a format of #,#,####,#. The #,#,#### portion of the string is the Framework version. for .NET 1.1, we use the name of the registry key itself, which represents the version number. Finally, if you look at dependencies, .NET 3.0 adds additional functionality to .NET 2.0 so both .NET 2.0 and .NET 3.0 must both evaulate as being installed to correctly say that .NET 3.0 is installed. Likewise, .NET 3.5 adds additional functionality to .NET 2.0 and .NET 3.0, so .NET 2.0, .NET 3.0, and .NET 3. should all evaluate to being installed to correctly say that .NET 3.5 is installed. .NET 4.0 installs a new version of the CLR (CLR version 4.0) which can run side-by-side with CLR 2.0.
针对.NET 4.5的更新
如果安装了。net 4.5,那么注册表中将没有v4.5键。相反,你必须检查HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full键是否包含一个名为Release的值。如果存在这个值,则表示安装了。net 4.5,否则没有。更多细节可以在这里和这里找到。