有没有办法从命令行确定 .NET Framework 版本?
为了解决安装问题,有时我只想快速了解安装的 .NET 版本。
除了查看目录之外,是否有其他方法可以确定标准 Windows 系统上的 .NET Framework 版本?
注意:这不适用于开发机器,只是开箱即用的 Windows
以下作品有效,但我正在寻找一种更简单的方法。
dir %WINDIR%\Microsoft.Net\Framework\v*
Directory of C:\Windows\Microsoft.Net\Framework
07/13/2009 07:20 PM <DIR> v1.0.3705
07/13/2009 07:20 PM <DIR> v1.1.4322
01/20/2010 01:16 PM <DIR> v2.0.50727
07/13/2009 09:37 PM <DIR> v3.0
01/20/2010 01:02 PM <DIR> v3.5
02/10/2010 03:20 AM <DIR> v4.0.21006
更新:不是解决方案,而是另一个很酷的目录格式列表
dir %WINDIR%\Microsoft.Net\Framework\v* /O :-N /B
v4.0.21006
v3.5
v3.0
v2.0.50727
v1.1.4322
v1.0.3705
To troubleshoot an installation, sometimes I just want a quick answer to what version of .NET is installed.
Is there a way to determine the .NET Framework version on a standard Windows system, other than looking at the directories?
NOTE: This is not for a development machine, just out-of-the-box windows
The following works, but I'm looking for a simpler way.
dir %WINDIR%\Microsoft.Net\Framework\v*
Directory of C:\Windows\Microsoft.Net\Framework
07/13/2009 07:20 PM <DIR> v1.0.3705
07/13/2009 07:20 PM <DIR> v1.1.4322
01/20/2010 01:16 PM <DIR> v2.0.50727
07/13/2009 09:37 PM <DIR> v3.0
01/20/2010 01:02 PM <DIR> v3.5
02/10/2010 03:20 AM <DIR> v4.0.21006
UPDATE: Not a solution, but another cool directory formatted listing
dir %WINDIR%\Microsoft.Net\Framework\v* /O:-N /B
v4.0.21006
v3.5
v3.0
v2.0.50727
v1.1.4322
v1.0.3705
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
顶部条目是安装的最新版本的框架。
注意:这不适用于该框架的 v1.x。
更新:我错过了您正在寻找一些内容可以通过电话告诉您爸爸的评论。如果是这种情况,上面的命令可能不是最适合您的方法。您最好告诉您的父亲打开 Windows 资源管理器并将他导航到 .NET Framework 目录并告诉您其中的数字。
The top entry is the latest version of the framework installed.
Note: This doesn't work with v1.x of the framework.
Update: I missed the comment that you are looking for something to tell your dad over the phone. If that's the case, the command above is probably not the best approach for you. You might be better off just telling your dad to open Windows Explorer and navigate him to the .NET Framework dir and telling you the numbers in there.
根据您的更新,表明这是为了让不懂技术的最终用户了解它,我建议访问 Scott Hanselman 的网站 http: //www.smallestdotnet.com(使用 Internet Explorer),它使用用户代理字符串告诉您拥有哪个 .NET Framework,并为您提供以最有效的方式获取最新版本的建议。
旧答案
使用PowerShell,你可以做到这一点(尽管PowerShell的存在已经意味着至少是.NET 2.0)
我不知道是否有类似的方法可以在普通的旧硬壳cmd.exe中获取版本信息。
Based on your update which indicates this is for walking a non-tech savvy end user through it, I suggest going to Scott Hanselman's site http://www.smallestdotnet.com (use Internet Explorer) which uses the user agent string to tell you which .NET Framework you've got and gives you recommendations for getting up to the latest version in the most efficient manner.
Old Answer
With PowerShell you could do this (although the presence of PowerShell already implies at least .NET 2.0)
I don't know if there's a comparable way to get the version information in plain old crusty cmd.exe.
只需打开 VS2008 命令提示符并输入 clrver
just open the VS2008 command prompt and type clrver
编辑:我的回答与OP问题无关(在我最初回答后进行了编辑)。
根据MSDN,您也可以使用注册表来检查已安装的版本。
另外这个网站声称有一个名为 csc 的命令行应用程序,您可以使用 - 不过还没有尝试过,我在运行安装期间使用注册表方式。
EDIT: my answer is irrelevant for the OP question (which was edited after I originally answered).
According to MSDN you can use the registry as well to check for installed versions.
In addition this site claims that there is a command line application called csc you can use - haven't tried it though, I use the registry way during installations I run.
以下命令将检测 .net Framework 3.5 是否安装。如果未安装,则安装它。只需在命令提示符下运行即可。
如果您想检测其他版本,只需根据情况将 v3.5 替换为 v2.0 或 v1.0 即可。此外,如果未检测到 .net,则 .net 框架的安装将以静默模式完成,即没有 UI 或用户交互。
The following would detect if .net framework 3.5 is installed or not.. and if not installed will install it. Just run this on the command prompt.
If you want to detect other versions just replace v3.5 with v2.0 or v1.0 as the case may be. Further if .net is not detected the installation of the .net framework would be done in silent mode i.e. no ui or user interaction.
CodeProject 上发布了一篇文章,它可以完全做到这一点及其命令基于线。
希望这有帮助。
There is an article posted on CodeProject that can do just exactly that plus its command line based.
Hope this helps.
该目录列表中的最高版本号是已安装的版本。
正如您所看到的,任何版本都包括所有以前的版本,因此检查特定版本的支持=检查该特定目录。
The highest version number from that directory listing is the installed version.
As you can see, any version includes all previous versions, so check for support of a specific version = check for that specific directory.