有没有办法从命令行确定 .NET Framework 版本? [英] Is there a way to determine the .NET Framework version from the command line?

查看:57
本文介绍了有没有办法从命令行确定 .NET Framework 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了解决安装问题,有时我只想快速了解安装的 .NET 版本.

To troubleshoot an installation, sometimes I just want a quick answer to what version of .NET is installed.

除了查看目录之外,还有其他方法可以确定标准 Windows 系统上的 .NET Framework 版本吗?

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.

目录 %WINDIR%Microsoft.NetFrameworkv*

Directory of C:WindowsMicrosoft.NetFramework

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

目录 %WINDIR%Microsoft.NetFrameworkv*/O:-N/B

v4.0.21006
v3.5
v3.0
v2.0.50727
v1.1.4322
v1.0.3705

推荐答案

根据你的更新表明这是为了让非技术精明的最终用户通过它,我建议去 Scott Hanselman 的网站 http://www.smallestdotnet.com(使用 Internet Explorer),它使用用户代理字符串来告诉您您使用的是哪个 .NET Framework并为您提供以最有效的方式升级到最新版本的建议.

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.

旧答案
使用 PowerShell 你可以做到这一点(尽管 PowerShell 的存在已经意味着至少 .NET 2.0)

Old Answer
With PowerShell you could do this (although the presence of PowerShell already implies at least .NET 2.0)

Get-ChildItem "$($Env:WinDir)Microsoft.NetFramework" -i mscorlib.dll -r |
    ForEach-Object { $_.VersionInfo.ProductVersion }

我不知道是否有类似的方法可以在普通的老壳 cmd.exe 中获取版本信息.

I don't know if there's a comparable way to get the version information in plain old crusty cmd.exe.

这篇关于有没有办法从命令行确定 .NET Framework 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆