Heaventools

   English English  Deutsch Deutsch

home  products  resource tuner console  sample scripts library

Localizing The Version Information

This code demonstrates how to make an application display the Version Information in different languages based on the user's locale.

RTC The script will create a copy of the Version Information for the German language. You have the option to change the TimeDate stamp and set every field in the PE file header, export, and resource sections to the adjusted TimeDate stamp.

The script performs the following operations on DemoApp1.exe:

  • Updates the Version Information, specifically the FileVersion and ProductVersion entries. The script receives numeric values for these entries through the placeholders from the LOCALIZE_VERSION_ INFO.BAT batch file located in the Demo folder.
  • Edits the String File Version Information.
  • Creates a copy of the StringFileInfo block statement for the German language.

The resulting modified file will be saved in the directory named "Release". You can check the log file "rtc.log" to see the changes made.

Note: when copying out the script code, please make sure there's no line-breaks. This is a requirement of VBScript: the entire command must be on one line.

Localize Version Information    (line-breaks solely for display purposes)

Sub Main
  PEFileProxy.PostDebugString "PE file header checksum updating is enabled." 
  PEFileProxy.UpdateCheckSum = True 

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

  ' Set the Language constants here
  LangID_US = 1033 ' English-US
  LangID_DE = 1031 ' German 
                   ' (LangIDs for other languagues can be found in the Help file)

  PEFileProxy.PostDebugString "Open the file for editing..."
  PEFileProxy.OpenFile ".\src\DemoApp1.exe"

  if not PEFileProxy.Terminated then
    if PEFileProxy.HasResources then

      ' Open the Version Info for editing
      if ResourcesProxy.OpenVersionInfo("1", LangID_US, CREATE_IF_NOT_EXIST) then

        ' Modify the FileVersion and ProductVersion entries using the placeholders
        VersionInfoProxy.SetFileVersion %plhd_VMajor%, %plhd_VMinor%, 0, 0,
  LangID_US, True, True, True
        VersionInfoProxy.SetProductVersion %plhd_VMajor%, %plhd_VMinor%, 0, 0,
  LangID_US, True, True, True
        
        ' Retrieve the Code Page
        CP = ScriptUnit.CodePageFromLangID(LangID_US)
        PEFileProxy.PostDebugString "CodePage value for English-US: " & CStr(CP)

       ' Edit the existing String File Version Information       
        S1 = "My Company"
        S2 = "Yet Another Super Application"
        S3 = "Hot product"
        S4 = "Copyright \0xA9 2024 My Company, Inc."
        S5 = "Your trademarks here..."
        S6 = "Super Application"
        S7 = "5.1.Zero.Null"

   VersionInfoProxy.EditStringFileInfo "CompanyName", S1, CP, LangID_US, True, True
   VersionInfoProxy.EditStringFileInfo "FileDescription", S2, CP, LangID_US, True, True
   VersionInfoProxy.EditStringFileInfo "InternalName", S3, CP, LangID_US, True, True
   VersionInfoProxy.EditStringFileInfo "LegalCopyright", S4, CP, LangID_US, True, True
   VersionInfoProxy.EditStringFileInfo "LegalTrademarks", S5, CP, LangID_US, True, True
   VersionInfoProxy.EditStringFileInfo "ProductName", S6, CP, LangID_US, True, True
   VersionInfoProxy.EditStringFileInfo "ProductVersion", S7, CP, LangID_US, True, True

        ResourcesProxy.CloseVersionInfo

      else
        ' Issue a warning in case of error
        PEFileProxy.PostDebugString "Can't open/create Version Info..."
      end if

'-------------------------Begin Adding New Language (DE) -------------------------

      if ResourcesProxy.OpenVersionInfo("1", LangID_DE, CREATE_IF_NOT_EXIST) then

        ' Modify the FileVersion and ProductVersion entries using the placeholders
        VersionInfoProxy.SetFileVersion %plhd_VMajor%, %plhd_VMinor%, 0, 0,  
  LangID_DE, True, True, True
        VersionInfoProxy.SetProductVersion %plhd_VMajor%, %plhd_VMinor%, 0, 0,  
  LangID_DE, True, True, True

       ' Specify the general file type: VFT_APP — an application, VFT_DLL — a DLL.       
        VersionInfoProxy.FileType = VFT_APP 

        ' Retrieve the Code Page
        CP = ScriptUnit.CodePageFromLangID(LangID_DE)
        PEFileProxy.PostDebugString "CodePage value for German: " & CStr(CP)

       ' Add the String File Version Information for German version      
        S1 = "Meine Firma"
        S2 = "Doch ein anderes Programm"
        S3 = "Eine heisse Software für innovative Anwender"
        S4 = "Copyright \0xA9 2024 Meine Firma GmbH"
        S5 = "Alle Rechte vorbehalten"
        S6 = "Super Programm"
        S7 = "5.1.Null.Null"

   VersionInfoProxy.EditStringFileInfo "CompanyName", S1, CP, LangID_DE, True, True
   VersionInfoProxy.EditStringFileInfo "FileDescription", S2, CP, LangID_DE, True, True
   VersionInfoProxy.EditStringFileInfo "InternalName", S3, CP, LangID_DE, True, True
   VersionInfoProxy.EditStringFileInfo "LegalCopyright", S4, CP, LangID_DE, True, True
   VersionInfoProxy.EditStringFileInfo "LegalTrademarks", S5, CP, LangID_DE, True, True
   VersionInfoProxy.EditStringFileInfo "ProductName", S6, CP, LangID_DE, True, True
   VersionInfoProxy.EditStringFileInfo "ProductVersion", S7, CP, LangID_DE, True, True

        ResourcesProxy.CloseVersionInfo
      else
        ' Issue a warning in case of error
        PEFileProxy.PostDebugString "Can't open/create Version Info..."
      end if
'--------------------------End Adding New Language-------------------------------

     ' Optionally you can change the TimeDate stamp and set every field in the 
     ' PE file header, export and resource sections to the adjusted TimeDate stamp.
     ' This operation is optional and can be commented out if not needed.
       
      MyDate = Now
      PEFileProxy.UpdateDateTimeStamp MyDate 

      'Save file 
      PEFileProxy.PostDebugString "Saving file as a new file image..." 
      PEFileProxy.SaveAsNewImage ".\release\DemoApp1.exe"

    end if
  end if
end sub

To view the changes made to the test EXE file, you can open it using Resource Tuner GUI.


SAMPLE SCRIPTS LIBRARY

Once installed Resorce Tuner Console, you will find the Demo Scripts folder nested within the directory where RTC has been installed. Within this Demo folder, there are 12 subdirectories containing script examples and sample executable files.

All sample scripts are ready to run. Select one of the .BAT files located within the Demo Scripts folders to execute the sample script. The script will make changes in the test EXE file. The resulting file will be created in the directory named Release under the directory containing the script.

The Complete Illustrated Step-by-Step Guide To Using Scripts

 Download Resource Tuner Console and learn how it can make you more productive.