C:\_G\WWW\~ELISANET\INFO\tscmd135.html
<http://www.elisanet.fi/tsalmi/info/tscmd135.html>
Copyright © 2003- by Prof. Timo Salmi  
Last modified Wed 7-Nov-2018 10:01:14

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.



135} How do I get information about a file extension association?

  @echo off & setlocal enableextensions
  ::
  if "%~1"=="" (
    echo Usage: %~0 .extension
    goto :EOF
    )
  set ext_=%~1
  ::
  echo %ext_%|find "=" > nul
  if %errorlevel% EQU 0 (
    echo Equal signs not allowed for safety reasons in %ext_%
    goto :EOF
    )
  ::
  for /f "tokens=2 delims==" %%a in (
    'assoc^|find /i "%ext_%"') do set assoc_=%%a
  echo %ext_% %assoc_%
  ::
  if defined assoc_ (
    reg query HKLM\SOFTWARE\Classes\%assoc_%|find "REG_SZ"
    echo.
    reg query HKLM\SOFTWARE\Classes\%assoc_%\shell|find "shell\"
    echo.
    for /f "tokens=1* delims==" %%a in ('assoc %ext_%') do ftype %%b
    ) else (
    echo No association)
  ::
  endlocal & goto :EOF

The output might be e.g.

  C:\_D\TEST>cmdfaq .html
  .html FirefoxHTML
      AlwaysShowExt REG_SZ
      <NO NAME>   REG_SZ  HTML Document
  HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell\Edit_with_Notepad
  HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell\open
  HKEY_LOCAL_MACHINE\SOFTWARE\Classes\FirefoxHTML\shell\Open_with_Mozilla
  FirefoxHTML=C:\PROGRA~1\MOZILL~1\FIREFOX.EXE -url "%1"

  C:\_D\TEST>cmdfaq .dir
  .dir
  No association

References/Comments:
  Google Groups Mar 5 2006, 7:30 am [M]
  Google Groups Mar 5 2006, 11:03 pm [M]

[Previous] [Next]

C:\_G\WWW\~ELISANET\INFO\tscmd135.html
C:\_G\WWW\~ELISANET\FTPCMD\TSALMI.CMD /tscmd135
http://www.elisanet.fi/tsalmi/info/tscmd135.html
file:///c:/_g/www/~elisanet/info/tscmd135.html