Resource Tuner Console

Content of the edit_my_exe.rts file:

' This sample VBScript code provides a real-world example that demonstrates
' many of the features available in Resource Tuner Console.
' This code shows how to replace the main application icon including images of all sizes
' (from 16x16 to 256x256) and color depths (from 4 bit to 32 bit) with new icon images from
' an external .ico file from the command-line.
' The script will add or replace icons in My_EXE_File.exe with icons from MyIcons.ico
' file in the "Demo\Src" folder. 
' The resulting files will reside in the directory named "Demo\Release"
' Check the log file to see the Resource Tree built.
' Resource Tuner Console Demo allows you to process only two files at a time. 
' Register to remove this limitation.

Sub Main
  PEFileProxy.PostDebugString "Updating the checksum in the PE file header is enabled." 
  PEFileProxy.UpdateCheckSum = True 

  PEFileProxy.PostDebugString "The creation of a backup copy is disabled." 
  PEFileProxy.CreateBackUp = False 

  LangID = 0 ' Default
  CP     = ScriptUnit.CodePageFromLangID(LangID)
  PEFileProxy.PostDebugString "Opening a file and checking resources..."

  if (PEFileProxy.OpenFileEx (".\demo\src\My_EXE_File.exe", True)) then

    ResourcesProxy.SetLanguage LangID, DELETE_IF_EXISTS

    PEFileProxy.PostDebugString "Changing/adding the icon set (All icons)..."
    ResourcesProxy.ChangeIcon "", LangID, CREATE_IF_NOT_EXIST, REPLACE_IF_ITEM_EXISTS_ELSE_ADD, ".\demo\src\MyIcons.ico"

    PEFileProxy.PostDebugString "Sorting out the icons..."
    ResourcesProxy.SortGroupIcon "", True

    PEFileProxy.PostDebugString ""
    PEFileProxy.PostDebugString "Resource Tree built by RTC:"
    PEFileProxy.PostDebugString ""

    PEFileProxy.PostDebugString "Saving file as a new file..."
    PEFileProxy.SaveAsNewImage ".\demo\release\My_EXE_File.exe"

    PEFileProxy.PostDebugString "Closing this file..."

    PEFileProxy.PostDebugString "Fatal error when opening the file."
  end if
end Sub

Content of the edit_my_exe.bat file:

rtc /L /F:"edit_my_exe.rts"