Is there a command line command for verifying what version of .NET is installed

前端 未结 9 837
孤街浪徒
孤街浪徒 2020-12-07 16:44

I have set of scripts for doing scripted installs. You can use the scripts on any server 2008 machine. However, I need to check if .NET 3.5 has been installed (before the

相关标签:
9条回答
  • 2020-12-07 17:05

    This is working for me:

    @echo off
    SETLOCAL ENABLEEXTENSIONS
    
    echo Verify .Net Framework Version
    
    for /f "delims=" %%I in ('dir /B /A:D %windir%\Microsoft.NET\Framework') do (
        for /f "usebackq tokens=1,3 delims= " %%A in (`reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\%%I" 2^>nul ^| findstr Install`) do (
            if %%A==Install (
                if %%B==0x1 (
                    echo %%I
                )
            )
        )
    )
    
    echo Do you see version v4.5.2 or greater in the list?
    
    pause
    
    ENDLOCAL 
    

    The 2^>nul redirects errors to vapor.

    0 讨论(0)
  • 2020-12-07 17:10

    You mean a DOS command such as below will do the job displaying installed .NET frameworks:

    wmic /namespace:\\root\cimv2 path win32_product where "name like '%%.NET%%'" get version
    

    The following may then be displayed:

    Version
    4.0.30319
    

    WMIC is quite useful once you master using it, much easier than coding WMI in scripts depending on what you want to achieve.

    0 讨论(0)
  • 2020-12-07 17:12

    You can write yourself a little console app and use System.Environment.Version to find out the version. Scott Hanselman gives a blog post about it.

    Or look in the registry for the installed versions. HKLM\Software\Microsoft\NETFramework Setup\NDP

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