Skip to content

Instantly share code, notes, and snippets.

@otonii
Created January 15, 2022 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save otonii/4fdba541c865513e14637b99c9375928 to your computer and use it in GitHub Desktop.
Save otonii/4fdba541c865513e14637b99c9375928 to your computer and use it in GitHub Desktop.
Extract Icon from .exe with PowerShell
Function ExtractIcon {
Param (
[Parameter(Mandatory=$true)]
[string]$folder
)
[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing') | Out-Null
md $folder -ea 0 | Out-Null
dir $folder *.exe -ea 0 -rec |
ForEach-Object {
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($_.FullName)
Write-Progress "Extracting Icon" $baseName
[System.Drawing.Icon]::ExtractAssociatedIcon($_.FullName).ToBitmap().Save("$folder\$BaseName.ico")
}
}
ExtractIcon -folder "C:\Path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment