17

Windows executable files (New or Portable executables) can contain icons. How can I extract them, either as ICO files or separate images?

0

5 Answers 5

26

There are a number of tools you can use.

icoutils, available as the eponymous package in many distributions, includes a tool capable of extracting resources from most Windows executables (16-bit NE, 32-bit PE, and 64-bit PE+), wrestool.

wrestool -x --output=. -t14 /path/to/windows.exe

will extract the icons present in the given Windows executable and write them to individual files, named after the executable name, with the type and icon name added.

7z can also extract all the resources in a Windows executable;

7z x /path/to/windows.exe .rsrc/ICON

will extract all the icons in the given Windows executable and write them to individual files in the .rsrc/ICON directory.

2
  • I can also recommend that wrestool command as being capable of extracting icons from 16-bit NE-format binaries now that so many Windows utilities lost support when the Windows APIs did.
    – ssokolow
    Feb 4, 2022 at 9:00
  • wrestool works fine, but 7z x just prints info and ends with "No files to process" and "Everything is Ok". If I use option -oOUTPUT_DIR instead of directly entering the output dir at the end, it tells me it detects 62 files indeed but only generates two binaries I cannot use (CPADinfo and prot).
    – hsandt
    Oct 3, 2023 at 14:46
2

To extract an icon from an executable file directly, if you have a Windows link pointing to that executable, you can use Wine's winemenubuilder command:

wine winemenubuilder -t /path/to/link.lnk /path/to/image-out.png

I believe the command will extract the image that the link would use, whether explicitly in the link or implicitly in its target.

If you need to generate a Windows link, you can use the mslink tool.

1

Using icoutils package available on most distros, you can use:

wrestool -xt14 -o. app.exe

It will extract all icons into current folder, you can change folder by changing -o. to -o /path/to/extract

Then use icotool to convert images inside an ico file to png image files:

icotool -x filename.ico

You can use wildcards to iterate all icons in a folder like this:

icotool -x *.ico
0

Depending on your distro, I like to use icoextract under Debian. Simple install via shell:

apt-get install icoextract

and run like:

icoextract /path/to/file.exe /path/to/file.ico

Find your new Icon file under

/path/to/file.ico

0

You can view and extract the entire contents of a DLL file on Linux using the "Resource Hacker" snap.

If you have Snap installed on your system, you can install it using the following command.

sudo snap install resourcehacker

enter image description here

Note: this is a Freeware Windows app running on Linux using Wine. Wine is contained in a snap container so it won't pollute your system.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .