Hopefully "ScriptingTipsAndTricks" helps you with your batch file or vbscript scripting :-)
[Bottom][Contents][Prev]: Delayed Expansion - in loops[Next]: Drag and Drop From Explorer - need to be careful about double quotes
\->Batch Files->Dot Net Versions - uses ASoft .NET Version Detector tool to get list

Dot Net Versions [uses ASoft .NET Version Detector tool to get list].cmd

The code below uses the free .NET version Detector from http://www.asoft.be/prod_netver.html (I have renamed "dotnet.exe" to "ASoft-Dot-Net-Version-Detector.exe").

I have included a version so that you can run this example however if you use it I recommend getting the latest version from ASoft's website.

[anchor]

The Code for: "Dot Net Versions [uses ASoft .NET Version Detector tool to get list].cmd"

This is the example, a shortcut was installed to this code :

@echo off
setlocal

call :GetDotNetVersions
     echo Install .NET Versions=%DotNetVersions%

goto :EOF



::===========================================================================
:GetDotNetVersions
::===========================================================================
    set DotNetVersions=
    set        TmpFile=%TEMP%\DotNetDetaction.%RANDROM%.txt
    ASoft-Dot-Net-Version-Detector.exe "%DotNetFile%" "%TmpFile%"
        set Mode=?
        for /F "usebackq delims=" %%d in ("%TmpFile%") do call :HandleDetectorFileLine "%%d"
    del "%TmpFile%" >nul 2>&1
    goto :EOF


::===========================================================================
:HandleDetectorFileLine
::===========================================================================
    ::--- Make the line safe to manipulate ----------------------------------
    set LineDQ=%1
    set LineDQ=%LineDQ:>=}%
    set LineDQ=%LineDQ:<={%
    set   Line=%LineDQ:"=%
    ::echo LINE: %Line%

    ::--- In section: ==== FOLDERS ==== ? -----------------------------------
    if not "%Line%" == "%Line: FOLDERS =DIFFERENT%" set Mode=F&set Bits=?& goto :EOF
    if not "%Mode%" == "F" goto NotInFOLDERS
       ::--- Look for "{32Bit}" and similar ---------------------------------
       set L1=%Line:~0,1%
       if "%L1%" == "=" set Mode=?& goto NotInFOLDERS
       if "%L1%" == "{" set Bits=%Line%& goto :EOF

       ::--- Look for "2.0.50727.3053" and similar --------------------------
       if "%L1%" == " " goto :EOF
          if not "%DotNetVersions%" == "" set DotNetVersions=%DotNetVersions%; &rem
                                          set DotNetVersions=%DotNetVersions%%Bits%%Line%
          goto :EOF
    :NotInFOLDERS

    ::--- In section: ==== Installed .NET Frameworks ==== ? -----------------
    if not "%Line%" == "%Line:Installed .NET Frameworks=DIFFERENT%" set Mode=I&goto :EOF
    if not "%Mode%" == "I" goto NotInINSTALLED
        ::--- Exit if at end of report --------------------------------------
        if not "%Line%" == "%Line:END REPORT=DIFFERENT%" set Mode=F&goto :EOF

        ::--- Capture this entry --------------------------------------------
        if not "%DotNetVersions%" == "" set DotNetVersions=%DotNetVersions%; &rem
                                        set DotNetVersions=%DotNetVersions%%Line%
        goto :EOF
    :NotInINSTALLED
    goto :EOF

Please note that that I am not trying to show how great I am by producing batch files 9,000 characters long on one line that no one will understand or be able to debug when they go wrong. I am going out of my way to comment the code and make it verbose so beginners and advanced users will both benefit. I don't claim to be an expert that knows everything, if I'm wrong or make a mistake then please contact me and let me know :-)


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: Delayed Expansion - in loops[Next]: Drag and Drop From Explorer - need to be careful about double quotes


ScriptingTipsAndTricks© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday September 07 2014 at 12:50pm
Visit ScriptingTipsAndTricks's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.