| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| CustodianSetup.exe | 2026-05-03 | 6.6 MB | |
| Custodian.zip | 2026-05-03 | 7.2 MB | |
| ReadMe.md | 2026-05-03 | 15.2 kB | |
| Totals: 3 Items | 13.9 MB | 0 |
Custodian Service Documentation
Overview
Custodian Service is a Windows service application that automatically manages file cleanup, archiving, and compression based on file age and configurable rules. The service runs in the background and can monitor multiple folders simultaneously with different processing rules for each.
Features
- Automatic File Management: Monitors folders and processes files based on age thresholds
- Multiple Processing Modes:
- Delete: Permanently removes old files
- Archive: Moves or copies files to archive location
- Zip: Compresses files into ZIP archives
- Flexible Scheduling: Configure different check intervals for each folder
- File Filtering: Use wildcard patterns to target specific file types
- Service Control: Supports standard Windows service operations (Start, Stop, Pause, Resume)
- Detailed Logging: Tracks all operations for auditing and troubleshooting
Installation
Prerequisites
- Windows operating system (Windows 7/Server 2008 R2 or later)
- Administrator privileges for installation
Installation Steps
- Copy Files
- Copy
Custodian.exeto your desired installation directory -
Example:
C:\Program Files\CustodianService\ -
Create Configuration File
- Create
config.iniin the same directory as the executable -
See Configuration section for details
-
Install the Service (as Administrator)
cmd cd "C:\Program Files\CustodianService" Custodian.exe /install -
Set Service Description (optional)
cmd sc description CustodianService "Automatically manages file cleanup, archiving, and compression based on age and configuration rules" -
Start the Service
cmd net start CustodianService
Or use Services console (services.msc):
- Find "Custodian Service"
- Right-click → Start
Uninstallation
-
Stop the Service
cmd net stop CustodianService -
Uninstall the Service
cmd Custodian.exe /uninstall -
Remove Files
- Delete the installation directory
Configuration
The service is configured using config.ini file located in the same directory as the executable.
Configuration Parameters
Required Parameters
| Parameter | Description | Example |
|---|---|---|
| Path | Folder path to monitor | C:\Temp |
| Days | Age threshold in days | 30 |
| Mode | Processing mode: Delete, Archive, or Zip | Delete |
| IntervalMinutes | Check interval in minutes | 60 |
Optional Parameters
| Parameter | Description | Default | Example |
|---|---|---|---|
| ArchivePath | Destination for Archive/Zip mode | N/A | D:\Archive |
| KeepOriginal | Keep original files (true/false) | false |
true |
| Mask1, Mask2, ... | File patterns to match | All files | *.log |
Processing Modes
Delete Mode
Permanently deletes files older than the specified threshold.
[Folder1]
Path=C:\Temp
Days=7
Mode=Delete
IntervalMinutes=60
Mask1=*.tmp
Mask2=*.cache
Behavior:
- Files matching the masks and older than 7 days are deleted
- No archive path needed
- Files are permanently removed
Archive Mode
Moves or copies files to an archive location.
[Folder2]
Path=C:\Production\Logs
Days=30
Mode=Archive
ArchivePath=D:\Archive\Logs
IntervalMinutes=360
KeepOriginal=false
Mask1=*.log
Behavior:
KeepOriginal=false: Files are moved to ArchivePath (original deleted)KeepOriginal=true: Files are copied to ArchivePath (original kept)- Original filename is preserved
- Archive folder is created automatically if it doesn't exist
Zip Mode
Compresses files into a ZIP archive.
[Folder3]
Path=C:\Backups
Days=90
Mode=Zip
ArchivePath=D:\Archive\backups.zip
IntervalMinutes=1440
KeepOriginal=false
Mask1=*.bak
Mask2=*.sql
Behavior:
- Files are added to the specified ZIP file
KeepOriginal=false: Original files are deleted after compressionKeepOriginal=true: Original files remain after compression- ZIP file is created automatically if it doesn't exist
- Files are appended to existing ZIP
File Masks (Wildcard Patterns)
Masks use Windows wildcard patterns to filter files:
| Pattern | Matches | Example |
|---|---|---|
*.log |
All .log files | error.log, app.log |
*.tmp |
All .tmp files | cache.tmp, temp.tmp |
test*.* |
Files starting with "test" | test1.txt, test_data.csv |
~*.* |
Files starting with ~ | ~tempfile.doc |
2024*.log |
Log files starting with 2024 | 20240115.log |
| (no masks) | All files | Everything in folder |
Multiple Masks:
Mask1=*.log
Mask2=*.txt
Mask3=*.bak
Mask4=*.tmp
Files matching any mask will be processed.
Common Interval Settings
| Frequency | Minutes | Use Case |
|---|---|---|
| Every hour | 60 | Temporary files |
| Every 6 hours | 360 | Application logs |
| Daily (midnight) | 1440 | Daily backups |
| Weekly | 10080 | Archive operations |
| Monthly | 43200 | Long-term cleanup |
Multiple Folder Monitoring
Monitor multiple folders by creating additional sections:
[Folder1]
Path=C:\Temp
Days=7
Mode=Delete
IntervalMinutes=60
[Folder2]
Path=C:\Logs
Days=30
Mode=Archive
ArchivePath=D:\Archive\Logs
IntervalMinutes=360
[Folder3]
Path=C:\Backups
Days=90
Mode=Zip
ArchivePath=D:\Archive\backups.zip
IntervalMinutes=1440
Important: Each folder section must start with [Folder (case-insensitive). Example: [Folder1], [Folder2], [FolderTemp], [FolderLogs]
Operation
Service Lifecycle
- Service Start
- Reads
config.ini - Initializes folder monitoring
- Schedules first check to run immediately
-
Logs startup information
-
During Operation
- Monitors folders based on configured intervals
- Processes files matching age and mask criteria
- Logs all operations
-
Responds to service control commands
-
Service Stop
- Completes current folder processing (if any)
- Logs shutdown
- Cleanly terminates
Service Control
Using Command Line
rem Start service
net start CustodianService
rem Stop service
net stop CustodianService
rem Pause service
net pause CustodianService
rem Resume service
net continue CustodianService
rem Check service status
sc query CustodianService
Using Services Console
- Press
Win + R, typeservices.msc, press Enter - Find "Custodian Service" in the list
- Right-click for options:
- Start
- Stop
- Pause
- Resume
- Restart
Service Properties
In Services console, right-click → Properties:
- Startup Type:
- Automatic: Starts with Windows
- Manual: Start manually when needed
-
Disabled: Prevents service from starting
-
Log On tab:
- Default: Local System (recommended for full access)
- Custom account: If specific permissions needed
Logging
Log File Location
Logs are written to: service.log in the same directory as the executable.
Example: C:\Program Files\CustodianService\service.log
Log Entries
The service logs all significant operations:
Service Events:
1/15/2026 10:00:00 AM Service started
1/15/2026 10:00:00 AM Service directory: C:\Program Files\CustodianService\
1/15/2026 10:00:00 AM Processing folder: C:\Temp
1/15/2026 2:30:45 PM Service paused
1/15/2026 2:35:12 PM Service resumed
1/15/2026 11:59:58 PM Service stopping
File Operations:
1/15/2026 10:05:23 AM Deleted: C:\Temp\oldfile.tmp
1/15/2026 10:05:24 AM Moved: C:\Logs\app.log -> D:\Archive\Logs
1/15/2026 10:05:25 AM Copied: C:\Data\report.pdf -> D:\Archive
1/15/2026 10:05:26 AM Zipped: C:\Backup\data.bak -> D:\Archive\backups.zip
1/15/2026 10:05:27 AM Zipped: C:\Backup\test.sql -> D:\Archive\backups.zip (kept original)
Errors:
1/15/2026 10:10:00 AM WARNING: Config file not found at C:\Program Files\CustodianService\config.ini
1/15/2026 10:15:32 AM Error processing folder C:\Temp: Access denied
1/15/2026 10:20:45 AM Error processing file C:\Temp\locked.tmp: The process cannot access the file because it is being used by another process
Log Management
The service does not automatically rotate or clean up log files. To manage log size:
- Manual cleanup: Periodically delete or archive
service.log - Automated cleanup: Use Windows Task Scheduler or another tool
- Monitor size: Check log file size regularly
Example log cleanup script:
@echo off
rem Archive old log file
copy "C:\Program Files\CustodianService\service.log" "C:\Archive\service_%DATE%.log"
del "C:\Program Files\CustodianService\service.log"
Troubleshooting
Service Won't Start
Problem: Service fails to start or stops immediately
Solutions:
- Check
service.logfor error messages - Verify
config.iniexists in the same directory as the executable - Ensure paths in
config.iniare valid - Verify service has necessary permissions (usually runs as Local System)
- Check Windows Event Viewer → Windows Logs → Application
Files Not Being Processed
Problem: Files remain in monitored folders
Possible Causes:
- Files not old enough: Check
Daysparameter - Mask mismatch: Files don't match any mask patterns
- Service paused: Check service status
- Interval not reached: Check
IntervalMinutesand when service started - Permission issues: Service can't access files
Debugging Steps:
rem Check service status
sc query CustodianService
rem View recent log entries
type "C:\Program Files\CustodianService\service.log"
Configuration Not Loading
Problem: Changes to config.ini not taking effect
Solution: Restart the service
net stop CustodianService
net start CustodianService
Configuration is only read at service startup.
Access Denied Errors
Problem: Log shows "Access denied" errors
Solutions:
- Verify service account has permissions to folders
- Check if files are locked by other processes
- Ensure archive destination is writable
- Run service as Local System (default) or account with appropriate permissions
Service Won't Stop
Problem: Service hangs when stopping
Possible Causes:
- Processing large number of files
- Waiting for file operations to complete
Solutions:
- Wait a few minutes for current operations to complete
- If truly hung, use Task Manager to end process (not recommended)
- Check
service.logfor last operation
Best Practices
Configuration
- Start Conservative: Begin with longer intervals and higher day thresholds
- Test First: Test configuration on non-critical folders before production
- Use Specific Masks: Target specific file types rather than all files
- Archive Before Delete: Consider archiving before switching to delete mode
- Backup Config: Keep backup copy of
config.ini
Monitoring
- Review Logs Regularly: Check
service.logweekly - Monitor Disk Space: Ensure archive destinations have adequate space
- Test Recovery: Verify you can restore archived files if needed
- Document Configuration: Keep notes on why each folder is configured
Security
- Limit Permissions: Only grant necessary folder access
- Secure Archive Location: Protect archive destinations
- Audit Trails: Preserve logs for compliance/auditing
- Test Restore: Regularly test file restoration from archives/ZIPs
Performance
- Stagger Intervals: Don't schedule all folders at same time
- Avoid Peak Hours: Schedule intensive operations during off-hours
- Monitor Resources: Watch CPU/disk usage during operation
- Limit File Count: Consider splitting large folders into multiple configurations
Example Configurations
Small Office - Basic Cleanup
[FolderTemp]
Path=C:\Windows\Temp
Days=7
Mode=Delete
IntervalMinutes=1440
Mask1=*.tmp
Mask2=*.temp
[FolderUserTemp]
Path=C:\Users\*\AppData\Local\Temp
Days=14
Mode=Delete
IntervalMinutes=1440
Application Server - Log Management
[FolderAppLogs]
Path=C:\ProgramData\MyApp\Logs
Days=30
Mode=Archive
ArchivePath=D:\Archive\AppLogs
IntervalMinutes=360
KeepOriginal=false
Mask1=*.log
Mask2=*.txt
[FolderWebLogs]
Path=C:\inetpub\logs
Days=90
Mode=Zip
ArchivePath=D:\Archive\WebLogs.zip
IntervalMinutes=1440
KeepOriginal=false
Mask1=*.log
Database Server - Backup Management
[FolderDailyBackups]
Path=C:\Backups\Daily
Days=7
Mode=Archive
ArchivePath=C:\Backups\Weekly
IntervalMinutes=1440
KeepOriginal=false
Mask1=*.bak
[FolderWeeklyBackups]
Path=C:\Backups\Weekly
Days=30
Mode=Zip
ArchivePath=D:\Archive\MonthlyBackups.zip
IntervalMinutes=10080
KeepOriginal=false
Mask1=*.bak
Technical Details
System Requirements
- OS: Windows 7 / Server 2008 R2 or later
- Permissions: Administrator for installation, Local System for operation
- Disk Space: Minimal (< 5 MB for executable)
- Memory: Minimal (< 10 MB typical usage)
File Processing Logic
- Service checks each configured folder at its specified interval
- For each file in the folder:
- Skip if it's a directory
- Skip if it doesn't match any mask (if masks specified)
- Check if file age > Days threshold
- If yes, process according to Mode
- Log all operations
- Schedule next check
Age Calculation
File age is calculated using the Last Write Time (modification date):
- Current time - Last Write Time > Days × 24 hours
- Uses system time (ensure system clock is correct)
Service Architecture
- Built using Borland C++ Builder VCL Framework
- Runs as Windows Service (SERVICE_WIN32_OWN_PROCESS)
- Single-threaded with event-based processing
- Uses high-resolution performance counters for scheduling
- Supports Pause/Resume operations
Support and Maintenance
Updating Configuration
- Stop the service
- Edit
config.ini - Start the service
Changes take effect immediately on service start.
Updating the Service
- Stop the service:
net stop CustodianService - Replace executable with new version
- Start the service:
net start CustodianService
Backing Up
Files to backup:
config.ini- Configurationservice.log- Operation history (optional)
Recommended backup location: Outside the service directory
Last Updated: January 2026