Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Extract Icon from File Using PowerShell

The following Powershell code can be used to Extract an Icon from a file. The extracted icon will be saved with an ico file type.

$Source = "C:\Path\To\SourceFile.exe"
$Target = "C:\Path\To\Icon.ico"

Add-Type -AssemblyName System.Drawing
$Bitmap = [System.Drawing.Icon]::ExtractAssociatedIcon($Source).ToBitmap()
$Icon = [System.Drawing.Icon]::FromHandle($Bitmap.GetHicon())
$File = New-Object System.IO.FileStream($Target, 'OpenOrCreate') 
$Icon.Save($File)
$File.Close()
$Icon.Dispose()


This post first appeared on Hinchley.net, please read the originial post: here

Share the post

Extract Icon from File Using PowerShell

×

Subscribe to Hinchley.net

Get updates delivered right to your inbox!

Thank you for your subscription

×