Pre-Execute Script
A Pre-Execute Script runs before any file is processed by this node.
This script acts as a gatekeeper for the node. If it returns true or 1, processing continues. If it returns false or 0, the node will not process the file.
This allows you to conditionally block execution based on system state or custom logic.
Return Values
The script must return one of the following values:
-
true or 1 Allows the node to continue processing the file.
-
false or 0 Prevents the node from processing the file.
Any other return value is treated as a failure and processing will be blocked.
Common Use Cases
- Prevent processing while a game or heavy application is running
- Check for available disk space
- Ensure a required service or process is running
- Block execution based on custom environment conditions
Examples
Block Processing While a Game Is Running (Windows)
This example C# script checks whether a game is currently running from common game installation directories. If a game is detected, processing is blocked and a notification is sent. You can expand or modify the directories to match your system.
string[] gamePaths = new string[]
{
@"C:\Program Files (x86)\Steam\steamapps\common",
@"C:\Games"
};
var runningGames = Process.GetProcesses()
.Select(process =>
{
try
{
string processPath = process.MainModule?.FileName ?? string.Empty;
return new { process.ProcessName, processPath };
}
catch
{
// Ignore processes where the path cannot be accessed
return null;
}
})
.Where(x => x != null && gamePaths.Any(path =>
x.processPath.StartsWith(path, StringComparison.OrdinalIgnoreCase)))
.ToList();
if (runningGames.Any())
{
StringBuilder log = new();
log.AppendLine("The following game(s) are currently running:");
foreach (var game in runningGames)
{
log.AppendLine($"- {game.ProcessName} ({game.processPath})");
}
Logger.ILog(log.ToString());
SendNotification("Information", "Game Running", log.ToString());
// Block processing
return false;
}
else
{
Logger.ILog("No games are currently running.");
// Allow processing
return true;
}
Notes
- This script runs once per file, before processing begins