I have this simple script - which seems to be how every search I find tells me to extract an icon for use:
$Format = [System.Drawing.Imaging.ImageFormat]::Icon
$Source = 'C:\Windows\System32\DeviceProperties.exe'
[System.Drawing.Icon]::ExtractAssociatedIcon($Source).ToBitmap().Save("c:\temp\extracted.ico",$Format)
Problem being that the resulting file is not a Windows icon file. As evidenced when you try to apply this icon to a shortcut or similar I receive this Windows error:
The file C:\Temp\extracted contains no icons
Choose an icon from the list or specify a diferent file
I'm assuming here it's because the result is a bitmap rather than an icon format.
The question is - how to convert this to a proper icon file ready for use?
The exported file: c:\temp\extracted.ico is a png file, not a ico file. I haven't found a way to convert this with powershell to ico format, either. But gimp e.g. can do this job.
Do the following:
This will convert the file format from png to ico and you won't lose transparency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With