I recently came across a FREE utility called IsCommandLineApp from Helge Klein, a little command-line tool that can be used to determine whether a specific executable is a command-line program. To run this against multiple executables manually is a kind of a pain, so I decided to write a PowerShell script that runs IsCommandLineapp against a defined Folder and all it’s subfolders.
To run the script, first download the IsCommandLineApp from here and then edit the variable $IsCommandLineApp so that it points to the location where you have stored the tool. If you want to search through another folder than C:\Windows change the variable $StartPath
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
<p># ===================================================================== <br /># Script Name : listcommandlineapps.ps1 <br /># Author: Alex Verboon <br /># Date: May 2012 <br /># Purpose: List all executables that are a commandline application <br /># =====================================================================</p> <p> <br />$ErrorActionPreference = "SilentlyContinue" <br />$IsCommandLineApp = "c:\Tools\IsCommandLineApp.exe" <br />$StartPath = "c:\windows\"</p> <p> <br />if (Test-Path $IsCommandLineApp) <br /> { <br /># IscommandlineApp.exe found <br /> } <br />else <br /> { <br /> echo($IsCommandLineApp + " not found. Download from <a href="http://helgeklein.com/free-tools/iscommandlineapp/")">http://helgeklein.com/free-tools/iscommandlineapp/")</a> <br /> exit <br /> }</p> <p> </p> <p>$stringA = "is not a"</p> <p>$files = get-childitem $StartPath -filter *.exe -recurse <br /> foreach ($file in $files) <br /> { <br />    $a = & $IsCommandLineApp $file.FullName <br />     if ( ($a.Contains($stringA))) <br />         { <br />         } <br />    Else <br />          { <br />        Write-output $a <br />         } <br /> }</p> |
To get all the results into a text file run listcommandlineapps.ps1 >allcmdapps.txt