iAmNewbe

NEW Resource Hacker version and How To get Delete Resources to work again from command line

3 posts in this topic

For those of you that use Resource Hacker it has recently been updated and the OLD way of using it's commands has changed.
I mainly use it to remove additional icon files from my executables but you can do other things with it also to alter your executables if you can't directly within AutoIT.

Resource Hacker
Version 4.5.30
Last updated: 27 November 2016
Resource Hacker Website

 

Since the new versions changed the command structure it took me forever to figure out how to make this work automagically in my scripts again. Here is what I figured out and what I still don't know.

This is the OLD command structure that no longer works with the newer and most recent version.

 

#AutoIt3Wrapper_Outfile=NameOfFile.exe
#AutoIt3Wrapper_Outfile_x64=NameOfFile.exe
#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -delete %out%, %out%, ICON, 1,
#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -delete %out%, %out%, ICON, 5,
#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -delete %out%, %out%, ICON, 11,
#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -delete %out%, %out%, ICONGROUP, 99,
#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -delete %out%, %out%, ICONGROUP, 162,
#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -delete %out%, %out%, ICONGROUP, 164,
#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -delete %out%, %out%, ICONGROUP, 169,

 

%out% is a Scite command, I am using that to write and compile my scripts from, Scite Editor.  
This is the name of your executable with the Path included.

%outx64% is the same as above but for 64 bit versions of your executable if it is named different than the non 64 bit version.

I just name both the same but it gets controlled by the "#AutoIt3Wrapper_UseX64=Y" directive if you want to use it or you can output both file versions using the compile utility "Ctrl+F7."  Probably shouldn't name both the same name if you do that.

The old version I was using you had to delete the Icons and the Icon Groups individually similar to above. In the new version this will give a fatal error, you are not allowed to directly access the Icons at all now. Instead you just delete the Icon Group and the icons associated to that group gets deleted automagically.

In the new version a problem I discovered that I can't get around. If you have spaces in the path for your executable Resource Hacker refuses to do anything and fails with an error.

Example:
%out% = c:\your work folder\subfolder work\NameOfFile.exe  <-- Spaces in path

 

According to resource hacker help you are suppose to wrap these with double quotes. Doing this though that command line fails which stops further Resource Hacker commands if you have any.  The error states something about the action doesn't exist or something to that extent.  What action?  No idea.

In the older versions of Resource Hacker though this worked for me but the new version it won't if there is spaces in the path for your executable file.
I got around this by directly naming the output file without a path, replacing the %out%, this saves it in the current working directory. I tried putting double quotes around %out% but again the command line failed so I gave up and just specifically named the file without a path.

Here is the NEW command structure you must use for DELETE.

#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -open fileName.exe -save fileName.exe -action delete -mask ICONGROUP,99,
#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -open fileName.exe -save fileName.exe -action delete -mask ICONGROUP,162,
#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -open fileName.exe -save fileName.exe -action delete -mask ICONGROUP,164,
#AutoIt3Wrapper_Run_After="C:\Resource Hacker\ResourceHacker.exe" -open fileName.exe -save fileName.exe -action delete -mask ICONGROUP,169,

 

1: You must now explicitly Open AND Save the executable. You were doing that before but it's reworked now so there is more you have to add to the command.
2:  For DELETING you have to use the actual command "-action"  then followed by the action in this specific case Delete.  "- action delete"
3: You have to tell Resource Hacker the Mask. I don't really know what that is but it seems to be the name of the resource like ICON or ICONGROUP followed by the name of the group like 99 or 164.  There are THREE comma's you have to use in the Mask but only Two are used. I don't know what the third one is for but if you don't add the third comma it doesn't work.

 

I add my own icons into my executable from within my script, not using Resource Hacker but the extra icons that are in the finished executable I don't want and I can't find a command to get rid of them from AutoIT side so that is why I use Resource Hacker.  The four Icon Groups above remove ALL the additonal Icons from my executable leaving only my own icons in the file which makes it a bit smaller in size too.

I hope you can benefit from my trial and error and head bashing to get this to work again. Also if you can figure out how to get %out% to work that would be great, I gave up on it.  

 

1 person likes this

Share this post


Link to post
Share on other sites



I was using a REALLY old version but I forgot how to use the commands and the hlp file it used for it's documentation won't open in Windows 10 so I went looking for a new version and the above is what I found and what I figured out.  It does work with 64 bit executables too, not sure if the one I was using did that or not.

Share this post


Link to post
Share on other sites

Good Job @iAmNewbe thanks for the heads Up ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now