Is there a way to determine the .NET Framework version from the command line?

前端 未结 7 955
北海茫月
北海茫月 2020-12-05 04:40

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

相关标签:
7条回答
  • 2020-12-05 05:04

    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.

    0 讨论(0)
  • 2020-12-05 05:13

    just open the VS2008 command prompt and type clrver

    0 讨论(0)
  • 2020-12-05 05:14

    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.

    0 讨论(0)
  • 2020-12-05 05:16

    There is an article posted on CodeProject that can do just exactly that plus its command line based.

    Hope this helps.

    0 讨论(0)
  • 2020-12-05 05:20

    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 exist "%WINDIR%\Microsoft.Net\Framework\v3.5" goto end start /wait .\Framework\dotnetfx.exe /q /norestart" :end 
    

    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.

    0 讨论(0)
  • 2020-12-05 05:24

    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)

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

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

    0 讨论(0)
提交回复
热议问题