Resource Tuner Console
'------------------------------------------------------------------------------
'
' Resource Tuner Console http://www.heaventools.com
'
' 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 batch process the contents of a directory.
' It processes specific file extensions (EXE, DLL, SYS, CPL) in the source directory.
'
' Note: Some Anti-Virus programs may alert you about malicious script
'       detected. Please ignore this alert.
'
' Resource Tuner Console Demo allows you to process only two files at a time. 
' Order the full version and enjoy it without limitations!
'
'------------------------------------------------------------------------------

'----------------------------------------------------------------------------
' ProcessFile
' 
' Purpose:
' 
' Processes a file: it sets the English-US language for all of the resources
' in the file, and then modifies/adds a Version Information resource.
'----------------------------------------------------------------------------

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  2, 0, 1, 122, LangID, True, True, True
        VersionInfoProxy.SetProductVersion 2, 0, 0, 0, LangID, True, True, True
        S1 = "Copyright \0xA9 1994-2008 SuperSoftware Development" 
        S2 = "SuperApp is a trademark of SuperSoftware Development" 
        S3 = "This file has been modified by Resource Tuner Console" 
        VersionInfoProxy.EditStringFileInfo "LegalCopyright", S1, CP, LangID, True, True
        VersionInfoProxy.EditStringFileInfo "LegalTrademarks", S2, CP, LangID, True, True
        VersionInfoProxy.EditStringFileInfo "Comments", S3, 1049, LangID, True, True
        ResourcesProxy.CloseVersionInfo 
        PEFileProxy.Compile 
        PEFileProxy.SaveAsNewImage Dest_Path & File_Name 
      Else 
        PEFileProxy.PostDebugString "Failed to open/create Version Info..." 
      End If 
    End If 
  End If 
End Sub 
'------------------------------------------------------------------------------ 

'------------------------------------------------------------------------------ 
' 
' The main routine. 
' 
' First, it scans the specified Source directory for files available.
' Then, for each file with specific file extension (EXE, DLL, SYS, CPL) 
' 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 = "sys" or FL_EXT = "cpl" then
      ProcessFile Src_Path, Dest_Path, File_Object.name
      PEFileProxy.PostDebugString "*************************************"
    End If

  next
end sub
'------------------------------------------------------------------------------