1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

whatruns - executable files

Discussion in 'T&T - Scripting' started by epement, Jan 6, 2012.

  1. epement

    epement

    Messages:
    61
    I have a batch file called "whatruns" that displays executable files. It's best explained by showing the internal help menu:
    Code:
    [c:\tmp] > whatruns --help
    WHATRUNS displays a list of executable files, by matching these filetypes:
    
      bat,cmd,btm       DOS batch files, TakeCommand/JPSoft batch file
      com,exe           binary executables
      pl,awk,py         perl, awk, python scripts
      sh,ksh            Bourne shell script, Korn shell script
      ade,adp           Microsoft Access Database (extension, project)
      cpl               Control Panel Extension
      hta               Hypertext Application
      ins,isp           IIS Network Settings script, IIS Service Provider script
      jse               JScript Encoded script
      msc,msi,msp,mst   Microsoft (CommonConsole,installer,patch,visual Test)
      scr,sct           Windows Screen Saver, Windows Script Component
      vb,vbe,vbs        Visual Basic (encoded, script)
      wsc,wsf,wsh       Windows Scripting (component, file, host)
    
    Default executable extensions are defined by the environment variable %PATHEXT%.
    Currently, PATHEXT=.COM;.EXE;.BTM;.BAT;.CMD;.VBS;.VBE;.JSE;.WSF;.WSH;.MSC
    
    WHATRUNS accepts directory names and /options appropriate to DIR.
    ~~~~~~~
    The following exectuable extensions are automatically BLOCKED by gmail.com,
    and may not be sent, even in an archive (.zip, .tar, .tgz, .taz, .z, .gz):
    
       "ade", "adp", "bat", "chm", "cmd", "com", "cpl", "exe",
       "hta", "ins", "isp", "jse", "lib", "mde", "msc", "msp",
       "mst", "pif", "scr", "sct", "shb", "sys", "vb",  "vbe",
       "vbs", "vxd", "wsc", "wsf", "wsh"
    
    We can get around this by sending them in a *.7z archive (www.7-zip.org).
    
    Here is the complete batch file:

    Code:
    @echo off
    :: filename: whatruns.btm
    ::   author: Eric Pement
    ::     date: 2011-10-12 17:15 CDT
    ::
    if "%1" == "/?" .OR. "%1" == "--help" goto syntax
    if "%1" == "" goto nopath
    if NOT ISDIR %1 goto nopath
    echo Executable files in %@full[%1\*.*] (sorted by file extension):
    echo.
    :: SETDOS options:
    :: /X-5 disables multiple commands, conditional commands, and piping (affects the
    :: command separator, ||, &&, |, and |&)
    setdos /X-5
    :: DIR opts: /4 = 4-column, kilobyte display
    ::           /k = no header             /v  = vertical sort
    ::           /o:e = sort by filetype    /ne = no error if no files found
    ::           /m = no summary footer
    dir %1\*.bat;*.cmd;*.btm;*.com;*.exe;*.pl;*.awk;*.sh;*.ksh;*.ad[ep];*.cpl;*.hta;*.ins;*.isp;*.ms[cipt];*.sc[rt];*.vb;*.vb[es];*.ws[cfh] /4kmvp /ne /o:e %2$
    setdos /X+5
    goto end
    
    :nopath
    echo Executable files in %_CWD (sorted by file extension):
    echo.
    setdos /X-5
    :: OLD-- dir *.bat;*.btm;*.cmd;*.com;*.exe;*.msc;*.pl;*.awk /4kmvp /o:e %$
    :: Windows EnvironmentVariable PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    dir %@replace[.,*.,%PATHEXT%];*.pl;*.awk;*.py;*.sh;*.ksh;*.ad[ep];*.cpl;*.hta;*.ins;*.isp;*.ms[ipt];*.sc[rt];*.vb;*.wsc /4kmvp /ne /o:e %$
    setdos /X+5
    goto end
    
    :syntax
    text
    WHATRUNS displays a list of executable files, by matching these filetypes:
    
      bat,cmd,btm       DOS batch files, TakeCommand/JPSoft batch file
      com,exe           binary executables
      pl,awk,py         perl, awk, python scripts
      sh,ksh            Bourne shell script, Korn shell script
      ade,adp           Microsoft Access Database (extension, project)
      cpl               Control Panel Extension
      hta               Hypertext Application
      ins,isp           IIS Network Settings script, IIS Service Provider script
      jse               JScript Encoded script
      msc,msi,msp,mst   Microsoft (CommonConsole,installer,patch,visual Test)
      scr,sct           Windows Screen Saver, Windows Script Component
      vb,vbe,vbs        Visual Basic (encoded, script)
      wsc,wsf,wsh       Windows Scripting (component, file, host)
    
    Default executable extensions are defined by the environment variable %PATHEXT%.
    endtext
    echo Currently, PATHEXT=%PATHEXT%
    
    text
    
    WHATRUNS accepts directory names and /options appropriate to DIR.
    ~~~~~~~
    The following exectuable extensions are automatically BLOCKED by gmail.com,
    and may not be sent, even in an archive (.zip, .tar, .tgz, .taz, .z, .gz):
    
       "ade", "adp", "bat", "chm", "cmd", "com", "cpl", "exe",
       "hta", "ins", "isp", "jse", "lib", "mde", "msc", "msp",
       "mst", "pif", "scr", "sct", "shb", "sys", "vb",  "vbe",
       "vbs", "vxd", "wsc", "wsf", "wsh"
    
    We can get around this by sending them in a *.7z archive (www.7-zip.org).
    endtext
    
    :end
    

Share This Page