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:
- Optionally set the English-US language for all resources in the file;
- Update the Version Info block (StringFileInfo, FileVersion, ProductVersion).
Upon execution, the resulting files will be saved to the RELEASE folder.
If the option USE_DATED_OUTPUT is set to True, the script will create a dated subfolder inside the RELEASE folder (e.g., RELEASE\2025-09-02\) and save all output files there. This helps organize outputs from different runs and prevents overwriting previous results.
If USE_DATED_OUTPUT is set to False, all files will be saved directly into the RELEASE folder.
[Logging] You can review the applied changes by checking the log file. Log output includes progress updates like
"Processing file #N of Total"
as well as debug/info messages.
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 ' ' Accepts: Source path, destination path, and filename. ' Purpose: ' - Optionally applies English-US language to all resources; ' - Updates Version Info resource block. ' '--------------------------------------------------------------------------------- sub ProcessFile (SrcPath, DestPath, FileName) ' Set the language ID to English-US (1033) LangID = 1033 ' Retrieve the corresponding CodePage (CP) and write it to the log CP = ScriptUnit.CodePageFromLangID(LangID) PEFileProxy.PostDebugString "CodePage: " & CStr(CP) & " for LangID 1033" 'Open file PEFileProxy.PostDebugString "[Action] Opening file and analyzing PE structure..." PEFileProxy.OpenFile Src_Path & File_Name If not PEFileProxy.Terminated Then If PEFileProxy.HasResources Then '----------------- Optional: Set language for all resources --------------------- ' ' Apply English-US (LangID 1033) to all resources. ' Uncomment the following section if you want to enforce English-US (1033) ' across all resources: ' PEFileProxy.PostDebugString "" ' PEFileProxy.PostDebugString "Setting English-US for all resources in file..." ' ResourcesProxy.SetLanguage LangID, SKIP_IF_EXISTS '-------------------------------------------------------------------------------- If ResourcesProxy.OpenVersionInfo("1", LangID, CREATE_IF_NOT_EXIST) Then ' Fill FileVersion and ProductVersion entries with Major, Minor, Release, ' and Build valuesusing placeholder values defined in the bat file PEFileProxy.PostDebugString "" PEFileProxy.PostDebugString "[Action] Set File/ProductVersion values..." VersionInfoProxy.SetFileVersion %plhd_Major%, %plhd_Minor%, %plhd_Release%, %plhd_Build%, LangID, True, True, True VersionInfoProxy.SetProductVersion %plhd_Major%, %plhd_Minor%, 0, 0, LangID, True, True, True 'Update the StringFileInfo entries PEFileProxy.PostDebugString "" PEFileProxy.PostDebugString "[Action] Populating StringFileInfo fields..." S1 = "Copyright \0xA9 2025 SuperSoftware Development" S2 = "SuperApp is a trademark of SuperSoftware Development" S3 = "Modified by RTC. Please buy a license after your evaluation period." VersionInfoProxy.EditStringFileInfo "LegalCopyright", S1, CP, LangID, True, True VersionInfoProxy.EditStringFileInfo "LegalTrademarks", S2, CP, LangID, True, True VersionInfoProxy.EditStringFileInfo "OriginalFilename", File_Name, CP, LangID, True, True VersionInfoProxy.EditStringFileInfo "Comments", S3, 1049, LangID, True, True ResourcesProxy.CloseVersionInfo 'Save the resulting file PEFileProxy.PostDebugString "" PEFileProxy.PostDebugString "Finalizing changes and saving updated file" PEFileProxy.SaveAsNewImage Dest_Path & File_Name Else ' Issue a warning in case of error PEFileProxy.PostDebugString "[Error] 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 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 Src_Path, Dest_Path dim File_System_Object, Folder_Object, File_Object, File_Collection dim FL_EXT, TotalCount, FileCount 'Enable checksum updating PEFileProxy.UpdateCheckSum = True PEFileProxy.PostDebugString "[Info] PE header checksum updating is enabled." 'Disable backup creation PEFileProxy.CreateBackUp = False PEFileProxy.PostDebugString "[Info] Backup skipped." 'Enable the plug-in subsystem PluginsProxy.Enabled = True PEFileProxy.PostDebugString "[Info] Plug-in subsystem is enabled." PEFileProxy.PostDebugString "[Info] RTC Demo allows processing only two files." ' Create FileSystemObject set File_System_Object = CreateObject("Scripting.FileSystemObject") ' Specify the path to the Source Folder Src_Path = ScriptUnit.CurrentFolder & "SRC\" ' ============================= Options ======================================== ' USE_DATED_OUTPUT: ' When set to True, the script will automatically create a subfolder inside ' the RELEASE folder named with the current date (in YYYY-MM-DD format), ' e.g., RELEASE\2025-09-02\. ' ' This is useful when processing multiple batches of files across different ' days — it helps keep outputs organized and prevents overwriting files from ' previous runs. ' ' Set to False to save all output files directly into the RELEASE\ folder ' without creating a date-based subfolder. ' ============================================================================== Const USE_DATED_OUTPUT = True ' Set to False to disable folder by date ' Configure Destination Path If USE_DATED_OUTPUT then dim Today Today = Year(Now) & "-" & Right("0" & Month(Now),2) & "-" & Right("0" & Day(Now),2) Dest_Path = ScriptUnit.CurrentFolder & "RELEASE\" & Today & "\" else Dest_Path = ScriptUnit.CurrentFolder & "RELEASE\" End If ' Ensure base folder RELEASE\ exists dim Base_Folder Base_Folder = ScriptUnit.CurrentFolder & "RELEASE\" if not File_System_Object.FolderExists(Base_Folder) then File_System_Object.CreateFolder Base_Folder PEFileProxy.PostDebugString "[Info] Created folder: " & Base_Folder End If ' Create dated folder if needed if not File_System_Object.FolderExists(Dest_Path) then File_System_Object.CreateFolder Dest_Path PEFileProxy.PostDebugString "[Info] Created output folder: " & Dest_Path End If ' Get list of files in source folder set Folder_Object = File_System_Object.GetFolder(Src_Path) set File_Collection = Folder_Object.Files ' Pass 1: Count how many files match extensions TotalCount = 0 for each File_Object in File_Collection 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" or FL_EXT = "cpl" then TotalCount = TotalCount + 1 End If Next ' Pass 2: Process matching files FileCount = 0 for each File_Object in File_Collection 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" or FL_EXT = "cpl" then FileCount = FileCount + 1 PEFileProxy.PostDebugString "" PEFileProxy.PostDebugString "****************************" PEFileProxy.PostDebugString " File #" & FileCount & " of " & TotalCount PEFileProxy.PostDebugString "****************************" ProcessFile Src_Path, Dest_Path, 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.