使用ResourceHacker以命令行方式更新应用程序图标

网上扒拉了一下,发现这玩意儿的命令行相关的介绍少之又少,找到的两个一个脚本之家的一个csdn的,内容一毛一样,反正就是不能用。

我这里用的是5.1.8版本的

在cmd或powershell中输入 ResourceHacker.exe -help commandline可以看到命令行具体用法,如下


====================================
Resource Hacker Command Line Syntax:
====================================

Command line instructions ...

Switch     Parameter
=========  ====================================================================
-open    : filename - the name of the file that is to be modified ...
           Windows PE file (*.exe, *.dll etc) or resouce file (*.res or *.rc)
-save    : filename - the new name of the modified or newly created file ...
           either a modified opened file or an extracted resource
-resource: filename - contains a resource being added to the opened file.
-action  : action to be performed on the opened file
           add             - add a resource, fails if it already exists
           addoverwrite - add a resource, overwrites if it already exists
           addskip        - add a resource, skips if it already exists
           compile        - compiles a text resource file (*.rc)
           delete          - delete a resource
           extract         - extract a resource
           modify         - modify a resource
           changelanguage(langID) - changes the language of ALL resources (nb: avoid any spaces)

-mask    : resource mask - Type,Name,Language
           commas are mandatory but each of type, name & language are optional
-log     : filename or CONSOLE or NUL
           CONSOLE: can be abbreviated to CON
           logs details of the operation performed
           switch is optional - if omited, defaults to resourcehacker.log
-script  : filename - contains a multi-command script, NOT a resource script
           for more info: -help script
           other switches are ignored.
-help    : options - commandline or script (always logged to CONSOLE)
           other switches are ignored.
=========  ====================================================================

Notes:
1. Switch identifiers may be abbreviated down to a single char (eg -res or -r).
2. Switch instructions do not have to be in any particular order.
3. File names that contain spaces must be encased within double quotes.
4. The changelanguage action changes the language ID of ALL resources irrespective of any mask.


Batch file Examples:
====================

CommandlineInstructions.bat:
  ResourceHacker.exe -help commandline
  @pause  :: and let's see the console output before the CMD window closes :)

Compile.bat:
  ResourceHacker.exe -open resources.rc -save resources.res -action compile -log NUL

AddIcon.bat:
  ResourceHacker.exe -open ".\In\old.exe" -save ".\Out\new.exe" -action addskip -res ".\In\missing.ico" -mask ICONGROUP,MAINICON,

ExtractIcon.bat:
  ResourceHacker.exe -open source.exe -save savedicon.ico -action extract -mask ICONGROUP,MAINICON, -log CONSOLE
  @pause

ExtractAllIcons.bat:
  ResourceHacker.exe -open source.exe -save savedicons.rc -action extract -mask ICONGROUP,, -log savedicons.log

RunScript.bat:
  ResourceHacker.exe -script myscript.txt

替换图标的话只需要这一条就够了

ResourceHacker.exe -open "要更改图标的文件" -save "更改后保存的名称" -action addoverwrite -res "图标" -mask ICONGROUP,MAINICON,0

具体用法参照上面的就行,懒得翻译

你可能感兴趣的:(ResourceHacker,windows)