Paste: deps.ps1

Author: erg (chatgpt)
Mode: powershell
Date: Sat, 1 Jun 2024 19:12:01
Plain Text |
# Path to your executable
$exePath = "c:\cygwin64\home\dougc\factor\factor.com"

# Function to get DLL version
function Get-DLLVersion {
    param (
        [string]$dllPath
    )
    $versionInfo = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($dllPath)
    return $versionInfo.FileVersion
}

# Get dependencies using dumpbin
$dependencies = & "c:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.35.32124\bin\HostX64\x64\dumpbin.exe" /DEPENDENTS $exePath | Select-String '\.dll' | ForEach-Object {
    $_.Line.Trim()
}

# Helper function to find DLL in system directories
function Find-DLLPath {
    param (
        [string]$dllName
    )
    $systemPaths = $env:PATH -split ';'
    $exeDirectory = Split-Path -Parent $exePath
    $pathsToCheck = $systemPaths + $exeDirectory

    foreach ($path in $pathsToCheck) {
        $fullPath = Join-Path -Path $path -ChildPath $dllName
        if (Test-Path $fullPath) {
            return $fullPath
        }
    }
    return $null
}

# Get version for each dependency
$dependencyVersions = @()
foreach ($dependency in $dependencies) {
    $dllPath = Find-DLLPath -dllName $dependency
    if ($dllPath) {
        $version = Get-DLLVersion -dllPath $dllPath
        $dependencyVersions += [PSCustomObject]@{
            DLL = $dependency
            Path = $dllPath
            Version = $version
        }
    } else {
        $dependencyVersions += [PSCustomObject]@{
            DLL = $dependency
            Path = "Not found"
            Version = "Not found"
        }
    }
}

# Display the results
$dependencyVersions | Format-Table -AutoSize

New Annotation

Summary:
Author:
Mode:
Body: