Skip to main content
Prism Launcher allows you to execute custom commands at different stages of instance launch and exit. These commands provide powerful automation and customization capabilities.

Command Types

There are three types of custom commands available:

Pre-Launch Command

Runs before the Minecraft instance starts. Useful for:
  • Setting up required services or configurations
  • Copying files or resources
  • Running initialization scripts
  • Validating system requirements

Wrapper Command

Wraps the entire Minecraft launch process. The wrapper command receives the Minecraft command as arguments. Common uses:
  • Performance tools (e.g., gamemoderun, mangohud)
  • GPU switching utilities (e.g., optirun, primusrun)
  • Debugging tools (e.g., gdb, strace)
  • Custom launchers or environment managers

Post-Exit Command

Runs after the Minecraft instance exits. Ideal for:
  • Cleanup operations
  • Backing up world saves
  • Resetting system configurations
  • Logging session information

Available Environment Variables

All custom commands are executed with special environment variables that provide context about the instance:
$INST_NAME
string
The display name of the instance
$INST_ID
string
The unique ID of the instance (typically the folder name)
$INST_DIR
string
Absolute path to the instance root directory
$INST_MC_DIR
string
Absolute path to the Minecraft game directory
$INST_JAVA
string
Path to the Java binary used for launch
$INST_JAVA_ARGS
string
Command-line parameters used for launch
This variable will not work correctly if arguments contain spaces. Use with caution.

Configuration

Custom commands can be configured at two levels:

Global Settings

Applies to all instances by default:
  1. Navigate to SettingsMinecraftCustom Commands
  2. Enter your commands in the respective fields

Per-Instance Settings

Override global settings for specific instances:
  1. Right-click an instance → Edit InstanceSettings
  2. Navigate to Custom Commands
  3. Check Override Global Settings
  4. Enter instance-specific commands

Examples

Pre-Launch Command Examples

#!/bin/bash
"$INST_JAVA" -jar packwiz-installer-bootstrap.jar "$INST_MC_DIR/pack.toml"

Wrapper Command Examples

gamemoderun

Post-Exit Command Examples

#!/bin/bash
cp -r "$INST_MC_DIR/saves" "$HOME/backups/$INST_ID-$(date +%Y%m%d)"

Advanced Usage

Using Scripts

For complex operations, use a script file:
#!/bin/bash
# Save as: pre-launch.sh

INSTANCE_DIR="$INST_MC_DIR"
MOD_DIR="$INSTANCE_DIR/mods"

# Update mods from packwiz
if [ -f "$INSTANCE_DIR/pack.toml" ]; then
    "$INST_JAVA" -jar packwiz-installer-bootstrap.jar "$INSTANCE_DIR/pack.toml"
fi

# Check for shader updates
if [ -d "$INSTANCE_DIR/shaderpacks" ]; then
    echo "Shader packs directory found"
fi

Conditional Execution

#!/bin/bash
if [ -f "$INST_MC_DIR/packwiz.jar" ]; then
    "$INST_JAVA" -jar "$INST_MC_DIR/packwiz.jar" refresh
fi

Working Directory

All custom commands are executed in the launcher’s working directory, not the instance directory. Use the environment variables (e.g., $INST_DIR, $INST_MC_DIR) to reference instance-specific paths.

Troubleshooting

Command Not Executing

  1. Check permissions: Ensure scripts have execute permissions (chmod +x script.sh on Linux)
  2. Use absolute paths: Always use full paths to executables and scripts
  3. Test independently: Run the command manually to verify it works
  4. Check logs: Review the launcher console for error messages

Arguments With Spaces

The $INST_JAVA_ARGS variable does not handle arguments containing spaces correctly. For complex argument processing, parse them manually in your script.

Script Encoding Issues

On Windows, ensure batch files use CRLF line endings. On Linux/macOS, use LF line endings.

Security Considerations

  • Be cautious when downloading and running commands from untrusted sources
  • Review scripts before execution to prevent malicious code
  • Avoid storing sensitive information in command strings
  • Use proper quoting to prevent command injection