How to get list of all programs on system PATH that countain some characters in powershell/batch

Freziyt223 20 Reputation points
2024-05-24T07:33:56.0666667+00:00
  • So, i want to make a builder file for my C code, i use Clang compiler and wanted to link the Windows SDK's headers and make it multiplatform, so even VS 2015 is supported.
  • I thought the easiest and best way will be to just find the programs that contain "developer prompt for VS", how can i do that in powershell script? Also, is there any more efficient way?

I use Windows 11, Windows 11 SDK, clang last version, powershell 7/5.1, Visual Studio Build tools 2022

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,603 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,237 questions
{count} votes

Accepted answer
  1. MotoX80 32,531 Reputation points
    2024-05-24T12:59:08.6666667+00:00

    This script will search folders listed in the path variable.

    $Search4 = "Microsoft.Windows.WinSqm"           # Look for this character string
    $PathFolders = $env:path.split(";")
    foreach ($Folder in $PathFolders) {
        "Analyzing folder $Folder"
        if (Test-Path $Folder) {
            $Files = Get-ChildItem -Path $Folder -File 
            foreach ($F in $Files) {
                $Data = Select-String -Path $F.FullName -Pattern $Search4 -Encoding unicode -ErrorAction SilentlyContinue
                if ($Data) {
                    "Unicode found in {0}" -f $f.FullName
                } else {
                    $Data = Select-String -Path $F.FullName -Pattern $Search4 -Encoding ascii -ErrorAction SilentlyContinue
                    if ($Data) {
                       "ASCII found in {0}" -f $f.FullName
                    }
                }
            }
        } else {
            "Folder does not exist."
        }
    }
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful