Heaventools

   English English  Deutsch Deutsch

Changing Version Variables And Updating The Version Information

This code shows how to change version variables (version numbers, product name, copyright strings, etc) from the command line.

Resource Tuner Console allows modification of file version information on all existing Windows EXE, DLL, or RES files in a folder. If a file contains no Version Info resource, Resource Tuner Console will create and add this resource for you.

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.

Edit Version Information

sub ProcessFile (SrcPath, DestPath, FileName)
  ' Set Language constant here
  LangID = 1033 ' English-US
  ' Retrieve the Code Page
  CP     = ScriptUnit.CodePageFromLangID(LangID)
  PEFileProxy.OpenFile SrcPath & FileName
  if not PEFileProxy.Terminated then
    if PEFileProxy.HasResources then
      ResourcesProxy.SetLanguage LangID, DELETE_IF_EXISTS
      if ResourcesProxy.OpenVersionInfo("1", LangID, CREATE_IF_NOT_EXIST) then
	  
        VersionInfoProxy.SetFileVersion  5, 1, 4, 20, LangID, True, True, True
        VersionInfoProxy.SetProductVersion 5, 1, 0, 0, LangID, True, True, True

        S1 = "My Company"
        S2 = "Yet Another Super Application"
        S3 = "Hot product"
        S4 = "Copyright \0xA9 2024 My Company, Inc."
        S5 = "your trademarks here..."
        S6 = "Next Big Thing"
        S7 = "Powered by Resource Tuner Console"

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

        ResourcesProxy.CloseVersionInfo
        PEFileProxy.Compile
        PEFileProxy.SaveAsNewImage DestPath & FileName
      else
        'Issue a warning in case of error
        PEFileProxy.PostDebugString "Can't open/create Version Info resource..."
      end if
    end if
  end if
end sub	

'----------------------------------------------------------------------------------
'
' The main routine.
'
' It processes specific file extensions in the source directory.
'
' First, it scans the spicified Source directory for files available.
' Then, for each file with specific file extension (EXE, DLL, RES) 
' it calls for the ProcessFile procedure.
'
'----------------------------------------------------------------------------------

Sub Main 
  dim SrcPath, DestPath, File_System_Object, Folder_Object, File_Object, File_Collection
  PEFileProxy.UpdateCheckSum = True
  PEFileProxy.CreateBackUp   = False

  ' Specify the path to the Source Folder
  SrcPath = ScriptUnit.CurrentFolder & "src\"

  ' Specify the path to the Destination Folder
  DestPath = ScriptUnit.CurrentFolder & "release\"

  ' Scan the specified folder, and then process all files found.
  set File_System_Object = CreateObject("Scripting.FileSystemObject")
  set Folder_Object      = File_System_Object.GetFolder(SrcPath)
  set File_Collection    = Folder_Object.Files
  for each File_Object in File_Collection

  ' Get an extension and modify it to one uniform lower case
  ' because there may be both upper and lower case characters
    FL_EXT = LCase(File_System_Object.GetExtensionName(File_Object.name))

  ' Check an extension and process specific file extension
    if FL_EXT = "exe" or FL_EXT = "dll" or FL_EXT = "res" then
      ProcessFile SrcPath, DestPath, File_Object.name
      PEFileProxy.PostDebugString "*************************************"
    end if
  Next 
End Sub

To see the changes made to the test EXEs, we recommend using Resource Tuner GUI, a visual resource editor.

Once installed Resorce Tuner Console, you will find the Demo folder nested in the directory where RTC has been installed. Within this Demo folder, there are 12 subdirectories that contain sample scripts and sample executable files.

All sample scripts are ready to run. Select one of the .BAT files located in the Demo 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.

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