# How Batch Script Automation Works in webMAN MOD: boot_init.txt and onxmb.bat Explained

> Learn how batch script automation in webMAN MOD works with boot_init.txt and onxmb.bat. Explore custom script execution during plugin load, service startup, and XMB entry.

- Repository: [Aldo Vargas/webman-mod](https://github.com/aldostools/webman-mod)
- Tags: how-to-guide
- Published: 2026-02-24

---

**WebMAN MOD executes custom batch scripts at three distinct lifecycle events—plugin load, service startup, and XMB entry—using an internal command engine that parses .bat files without invoking an external shell.**

webMAN MOD includes a lightweight **batch script automation** system that allows users to automate tasks on a PlayStation 3 without modifying the plugin's source code. The system recognizes three special script files that trigger at deterministic moments in the plugin's lifecycle, enabling everything from cold-boot configuration to post-game cleanup.

## The Three Automation Triggers

The batch script engine monitors for three specific events, each associated with a hardcoded file path defined in [`include/init/paths.h`](https://github.com/aldostools/webman-mod/blob/main/include/init/paths.h) and documented in the bundled [`help.html`](https://github.com/aldostools/webman-mod/blob/main/help.html) file.

### Plugin Load: boot_init.txt

When the webMAN MOD PRX is first injected into memory, the engine checks for **[`/dev_hdd0/boot_init.txt`](https://github.com/aldostools/webman-mod/blob/main//dev_hdd0/boot_init.txt)**. If present, the script executes immediately **before** any network services (FTP, HTTP, netiso) are initialized.

This trigger is ideal for one-time configuration tasks such as mounting SMB shares, setting environment variables, or creating symbolic links. The constant `BOOT_INIT_TXT` in [`include/init/paths.h`](https://github.com/aldostools/webman-mod/blob/main/include/init/paths.h)【L220】 defines this default location.

### Services Started: autoexec.bat

After webMAN MOD has successfully started its background services—FTP server, HTTP interface, and netiso support—the engine looks for **`/dev_hdd0/autoexec.bat`**. This script runs exactly once per plugin initialization, making it suitable for launching custom daemons, copying fresh configuration files, or starting homebrew applications that depend on network services.

### XMB Loaded: onxmb.bat

Every time the XMB (PlayStation 3 system menu) appears, the engine executes **`/dev_hdd0/onxmb.bat`**. This includes cold boots, returning from a game, or manually invoking the XMB. According to the source code in [`main.c`](https://github.com/aldostools/webman-mod/blob/main/main.c), this check occurs within the main event loop that watches for `XMB_LOADED` events.

This trigger is perfect for maintenance tasks that must occur after gameplay ends, such as cleaning temporary caches or remounting drives.

## The Batch Script Engine Architecture

Unlike traditional batch processing that shells out to an external interpreter, webMAN MOD implements an **internal command parser** that reads scripts line-by-line and maps commands directly to internal C functions. This design prevents security risks by restricting operations to the WebMAN-MOD command set.

The parser supports conditional logic (`if/else if/else/end if`), existence checks (`if exist <path>`), and hardware detection (`if cobra`, `if mamba`, `if ps3hen`). File-system operations—including `copy`, `fcopy`, `del`, `md`, `map`, and `unmap`—execute via `cellFs*` system calls. Flow control commands like `goto`, `label`, `while`, `break`, and `continue` manage execution paths.

Command implementations reside in the `include/cmd/` directory (specifically files like [`refresh.h`](https://github.com/aldostools/webman-mod/blob/main/refresh.h) and related `.c` modules), where each recognized token maps to a specific internal function.

## Practical Code Examples

### Cold-Boot Configuration with boot_init.txt

Use this script to mount an SMB share automatically when the plugin loads:

```bat

# boot_init.txt

if not exist /dev_hdd0/tmp/smb_mounted
{
    map //smb_server/share /dev_hdd0/tmp/smb_mounted
    echo "SMB share mounted" > /dev_hdd0/tmp/smb_mounted.log
}

```

The `map` command creates a virtual mount point, and the conditional ensures the operation runs only once per cold boot.

### Post-Service Initialization with autoexec.bat

Guarantee a fresh configuration file after services start:

```bat

# autoexec.bat

del /dev_hdd0/tmp/wm_config.bin
copy /dev_hdd0/backup/wm_config.bin /dev_hdd0/tmp/wm_config.bin
echo "Config reloaded" > /dev_hdd0/tmp/reload.log

```

This executes after the FTP and HTTP servers are alive, ensuring the configuration is refreshed before any network interactions.

### XMB Event Handling with onxmb.bat

Clean temporary folders every time you return to the XMB:

```bat

# onxmb.bat

del /dev_hdd0/tmp/wmtmp/*
md /dev_hdd0/tmp/wmtmp/cover_cache
echo "Temp folders cleared at $(date)" > /dev_hdd0/tmp/clean.log

```

This script triggers after exiting any game, maintaining disk space automatically.

### Conditional Logic and Firmware Checks

Adapt behavior based on firmware version:

```bat

# onxmb.bat

if firmware >= 4.82
{
    copy /dev_hdd0/modern_plugin.sprx /dev_hdd0/boot_plugins.txt
}
else
{
    copy /dev_hdd0/legacy_plugin.sprx /dev_hdd0/boot_plugins.txt
}

```

The engine evaluates firmware comparisons at runtime, allowing scripts to handle different PS3 system software versions.

## Source Code Implementation Details

The automation system is implemented across several key files in the aldostools/webman-mod repository:

- **[`include/init/paths.h`](https://github.com/aldostools/webman-mod/blob/main/include/init/paths.h)**【L220】 – Defines the constant paths for [`boot_init.txt`](https://github.com/aldostools/webman-mod/blob/main/boot_init.txt), `autoexec.bat`, and `onxmb.bat`
- **[`main.c`](https://github.com/aldostools/webman-mod/blob/main/main.c)** – Contains the main event loop that detects XMB load events and invokes the script runner for `onxmb.bat`
- **[`include/cmd/refresh.h`](https://github.com/aldostools/webman-mod/blob/main/include/cmd/refresh.h)** and related `.c` files – Implement the command parser that maps batch commands like `copy`, `map`, and `if` to internal functions
- **[`_Projects_/updater/update/dev_hdd0/xmlhost/game_plugin/help.html`](https://github.com/aldostools/webman-mod/blob/main/_Projects_/updater/update/dev_hdd0/xmlhost/game_plugin/help.html)**【L27】 – Provides the complete command reference and event table documentation

The pseudocode execution flow in [`main.c`](https://github.com/aldostools/webman-mod/blob/main/main.c) follows this pattern: check for `BOOT_INIT_TXT` on load, start services, check for `AUTOEXEC_BAT`, then enter a loop that monitors for `XMB_LOADED` events to trigger `ONXMB_BAT`.

## Summary

- **webMAN MOD** provides three automation hooks: [`boot_init.txt`](https://github.com/aldostools/webman-mod/blob/main/boot_init.txt) (plugin load), `autoexec.bat` (services started), and `onxmb.bat` (XMB entry).
- The **internal command engine** parses scripts directly without external shell invocation, using implementations in `include/cmd/*.h` and `.c` files.
- **Supported commands** include conditionals, file operations (`copy`, `del`, `map`), and flow control (`goto`, `while`), documented in the bundled [`help.html`](https://github.com/aldostools/webman-mod/blob/main/help.html).
- **File paths** are defined as constants in [`include/init/paths.h`](https://github.com/aldostools/webman-mod/blob/main/include/init/paths.h), defaulting to `/dev_hdd0/` for all three script types.
- **Security** is maintained by restricting operations to the WebMAN-MOD command set, preventing arbitrary system execution.

## Frequently Asked Questions

### What commands are supported in webMAN MOD batch scripts?

The engine supports conditional statements (`if`, `else if`, `else`, `end if`), file operations (`copy`, `fcopy`, `del`, `md`, `map`, `unmap`), flow control (`goto`, `label`, `while`, `break`, `continue`), and hardware checks (`if cobra`, `if mamba`, `if ps3hen`, `if firmware`). The complete reference is available in the [`help.html`](https://github.com/aldostools/webman-mod/blob/main/help.html) file bundled with the plugin.

### Can I use standard Windows batch syntax in these files?

No, webMAN MOD uses a proprietary command syntax that resembles Windows batch files but is parsed by an internal engine. Commands map directly to C functions in the `include/cmd/` modules rather than being passed to an external shell interpreter, which limits syntax to the specific command set documented in the help files.

### Where are the script files stored on the PS3?

By default, all three automation scripts reside in `/dev_hdd0/`: [`boot_init.txt`](https://github.com/aldostools/webman-mod/blob/main/boot_init.txt) for plugin initialization, `autoexec.bat` for post-service tasks, and `onxmb.bat` for XMB events. These paths are defined as constants in [`include/init/paths.h`](https://github.com/aldostools/webman-mod/blob/main/include/init/paths.h) and can be referenced using the repository's source code.

### How does the onxmb.bat script know when to execute?

The script triggers every time the XMB (system menu) becomes visible, including after cold boots and when returning from games. The main execution loop in [`main.c`](https://github.com/aldostools/webman-mod/blob/main/main.c) monitors for `XMB_LOADED` events and checks for the existence of `onxmb.bat` before running the internal batch parser.