home products resource tuner console sample scripts library
Batch Processing All Executable Files in a Folder
This sample code provides a real-world example that demonstrates many of the features available in Resource Tuner Console. The code shows how to batch process the contents of a directory containing mixed EXEs and DLLs.
The script scans the specified Source directory for all available files. Then, for each file with the given file extension (EXE, DLL, SYS) it calls for the ProcessFile procedure to set the English-US language for all resources in each file and update the Version Information resource (StringFileInfo, FileVersion, and ProductVersion values). The processed files will be saved in the Destination folder.
Note: Ensure that there are no line breaks in the script code, as VBScript requires the entire command to be on one line.
'--------------------------------------------------------------------------------- ' ' This code shows how to batch process the contents of a directory. ' It processes specific file extensions (EXE, DLL, SYS) in the source directory. ' '--------------------------------------------------------------------------------- ' ProcessFile procedure ' ' Purpose: ' ' Sets the English-US language for all resources in the file ' and updates the Version Information resource: ' StringFileInfo, FileVersion, and ProductVersion values. ' '--------------------------------------------------------------------------------- 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 2, 0, 1, 122, LangID, True, True, True VersionInfoProxy.SetProductVersion 2, 0, 0, 0, LangID, True, True, True S1 = "Copyright \0xA9 2024 SuperSoftware Development" S2 = "SuperProg is a trademark of SuperSoftware Development" S3 = "This file 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 DestPath & FileName Else ' Issue a warning in case of error 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 folder for available files. ' Then, for each file found, it calls the ProcessFile procedure. ' ' Resource Tuner Console Demo allows processing only two files at a time. ' Order the full version and enjoy it without limitations! ' '------------------------------------------------------------------------------ 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 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 if the file has the specified file extension and process specific file ' extension. Add or remove file extensions as needed. If FL_EXT = "exe" or FL_EXT = "dll" or FL_EXT = "sys" Then ProcessFile SrcPath, DestPath, File_Object.name PEFileProxy.PostDebugString "*************************************" End If Next End Sub
To view the changes made to the test EXE and DLL files, you can open them using Resource Tuner GUI.
SAMPLE SCRIPTS LIBRARY
Upon installing Resource Tuner Console, you will find the Demo Scripts
folder nested within the RTC installation directory. This folder contains 12 subdirectories, each featuring script examples and sample executable files.
All the sample scripts are ready to run. To execute a sample script, simply select one of the .BAT files located within the respective Demo
folders. When executed, the script will apply changes to the test EXE file. The resulting modified file will be created in a directory named Release
, which resides in the same directory as 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.