WinRar archive with iimg and iicon options becomes

2019-05-21 06:42发布

I'm trying to create a self-extractable (SFX) rar archive, which will have both icon and image. I'm using the following command line:

winrar.exe a -r0 -sfx -ibck -z"MyConfFile.conf" -iimg"MyImage.bmp" -iicon"MyIcon.ico" MyPackage.exe @"MyFileList.txt"

Trouble is - the resulting .exe can't be unpacked. Instead it says "The archive is either in unknown format or damaged". If I set only icon or only image, then everything is fine. But if I set both, I'm in trouble. Strangest thing.

标签: winrar sfx
1条回答
Deceive 欺骗
2楼-- · 2019-05-21 07:00

The code of the SFX module + the data of the bitmap file + data of the icon file + SFX comment file + other data (signature) are written first to the SFX archive file and next the actual archive with the compressed data is appended to the file.

The maximum size of all data preceding the archive data must be at the moment smaller than 1 MB according to RAR 5.0 archive format technote documentation.

Possible solutions:

  • Reduce the size of the bitmap file by making it smaller in width/height.
  • Reduce the size of the bitmap file by decreasing the colors from true color to 256 colors.
  • Reduce the size of the icon file by removing icons from icon file not really needed as a single icon in the dimensions 16x16, 24x24, 32x32 and 48x48 is enough. Some *.ico files contain multiple icons in various dimensions. A single icon in the standard dimensions is enough for an SFX archive. It is even possible to remove some sizes like 24x24 and 48x48 so that the icon file contains only one icon in dimensions 16x16 and 32x32.
  • Reduce the size of the icon file by decreasing all true color icons in the file to icons with only 256 colors using a customized palette or even to 16 colors if that is possible.
  • Reduce the size of the comment file if that is somehow possible like using wildcards for files to delete before installation or shorter text displayed to user on SFX execution.
  • Reduce the size of the SFX module for example by compressing it with UPX.

But take into account that with compression of the SFX module itself the bitmap and the icon must be in the resources of the SFX module itself instead of being appended separately.

A tool like Resource Hacker can be used to replace the standard bitmap by own bitmap and the standard icons by own icons as well as changing dialog layout. That reduces the total size of the data preceding the archive data even without compressing the SFX module with a runtime packer like UPX.

Using tools like Resource Hacker to customize the resources of one of the standard SFX modules of WinRAR is permitted by the copyright owners of WinRAR. See in help of WinRAR (winrar.chm) the page with title GUI RAR and ZIP SFX modules (Default.SFX and Zip.SFX) via Index tab or via Contents tab (first entry of Self-extracting modules) of help.

查看更多
登录 后发表回答