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:The display name of the instance
The unique ID of the instance (typically the folder name)
Absolute path to the instance root directory
Absolute path to the Minecraft game directory
Path to the Java binary used for launch
Command-line parameters used for launch
Configuration
Custom commands can be configured at two levels:Global Settings
Applies to all instances by default:- Navigate to Settings → Minecraft → Custom Commands
- Enter your commands in the respective fields
Per-Instance Settings
Override global settings for specific instances:- Right-click an instance → Edit Instance → Settings
- Navigate to Custom Commands
- Check Override Global Settings
- Enter instance-specific commands
Examples
Pre-Launch Command Examples
Wrapper Command Examples
Post-Exit Command Examples
Advanced Usage
Using Scripts
For complex operations, use a script file:Conditional Execution
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
- Check permissions: Ensure scripts have execute permissions (
chmod +x script.shon Linux) - Use absolute paths: Always use full paths to executables and scripts
- Test independently: Run the command manually to verify it works
- Check logs: Review the launcher console for error messages
Arguments With Spaces
Script Encoding Issues
On Windows, ensure batch files use CRLF line endings. On Linux/macOS, use LF line endings.Security Considerations
Related Documentation
- Environment Variables - Configure custom environment variables
- Command-Line Arguments - Launch instances from the command line
- Portable Mode - Run Prism Launcher in portable mode
