Heaventools

   English English  Deutsch Deutsch  Русский Русский

home  products  resource tuner console  sample scripts library

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.

RTC ScriptResource 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. Every field in the VERSIONINFO structure is under your control.

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.

'------------------------------------------------------------------------------
'
sub ProcessFile (Src_Path, Dest_Path, File_Name)
  LangID = 1033 ' English-US
  CP     = ScriptUnit.CodePageFromLangID(LangID)
  PEFileProxy.OpenFile Src_Path & File_Name
  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 2017 My Company, Inc."
        S5 = "your trademarks here..."
        S6 = "Super Editor"
        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 Dest_Path & File_Name
      else
        PEFileProxy.PostDebugString "Can't open/create Version Info..."
      end if
    end if
  end if
end sub	
'----------------------------------------------------------------------------------
'----------------------------------------------------------------------------------
'
' The main routine.
'
' First, it scans the specified Source folder for EXE files available.
' Then, for each file found it calls for the ProcessFile procedure.
'
'----------------------------------------------------------------------------------

Sub Main 
  dim Src_Path, Dest_Path, File_System_Object, Folder_Object, File_Object, File_Collection
  PEFileProxy.UpdateCheckSum = True
  PEFileProxy.CreateBackUp   = False
  ' Specify the path to the Source Folder
  Src_Path = ScriptUnit.CurrentFolder & "src\"
  ' Specify the path to the Destination Folder
  Dest_Path = 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(src_path)
  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" or FL_EXT = "sys" then
      ProcessFile Src_Path, Dest_Path, 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 in the directory where RTC has been installed. Within this Demo folder, there are 11 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.

 

The Complete Illustrated Step by Step Guide To Using Scripts

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