Skip to content
SirNapkin1334 edited this page Apr 25, 2018 · 23 revisions

GodMode9 has featured a scripting engine since version 1.2.7.

Scripts are formatted as plaintext ASCII with a .gm9 file extension, and allow the automation of complex tasks.

Running a Script

All scripts placed in the /gm9/scripts folder on the SD card will show up on the Scripts menu (HOME button -> Scripts...) and can be conviniently executed from there.

To run a script that's not present in this folder, it can be manually executed by navigating to it and choosing "Execute GM9 Script" from its context menu.

Basics

GodMode9 scripts resemble shell scripts. Comments are denoted by # and work anywhere. Variable are in the format $[VAR] where VAR is the name of the variable. (i.e. $[HAX]). Surround an argument with " if it must contain whitespaces. Any redundant whitespaces outside of " will be treated as a single whitespace. An unknown command will lead to a script abort.

Wildcards

A wildcard is a character that will be seen as any character or sequence of characters in a search. GodMode9 has support for two types of Wildcards, * and ?. * will check for anything of any length, while ? will check for only one character (multiple ? can be used in a row to make a set amount of characters).

-o and -s Switches

You can use -o and/or -s switches on any command, or --optional / --silent respectively. -o Continues on failures of a command, and -s will try to suppress all error messages. Example: ask -o -s "Perform this operation (I will completely ignore your response)?"

Commands

A short description of every command. Click on the command to go to a more detailed page about it. <> Denotes a required parameter. [] denotes an optional parameter.

echo command - Outputs data to the screen. Syntax: echo "<text to be outputted>" Example: echo "Hello There!"

qr command - Does the same as echo but also displays a QR on the top screen. Syntax: qr <message> <qr data> Example: qr "Scan for cool stuff! ;)" "https://github.com/d0k3/GodMode9"

chk command - Checks two values against each other. Syntax: chk <value1> <value2> Example: chk $[HAX] a9lh

ask command - Similar to echo, but allows user to abort script. Syntax: ask <message> Example: ask "Continue running this script? Note: using -o command allows you to ignore user response.

set command - allows you to create variables and edit ERRORMSG and SUCCESSMSG Syntax: set <varname> <data> Example: set TESTPATH 0:/3ds/

input command - allows you to prompt the user to enter a string and store it in a variable. Syntax: input <prompt> <varname> Example: input "Choose name for test dir?" DIRNAME Note: the variable can be created beforehand with set to preset the initial value.

filesel command - allows the user to choose a file from in a specific directory / drive. The path is stored in a variable and can be limited via wildcards. Syntax: filesel [-d] <prompt> <path> <var> Example: filesel "Please select NAND backup" 0:/gm9/out/*_$[SERIAL]_???nand_???.bin NANDBAK

[more to come ofc]

Environment Variables

Environment Variables are variables that are always available, no matter what. They are determined when GodMode9 boots, and cannot be changed via scripting commands. Remember, when including a variable in a command, use $[VAR] where VAR is the name of the variable (i.e. $[HAX]).

  • GM9VER - the version of the currently running GodMode9 firm. (i.e. v5.0.0)
  • REGION - the region of the console's SysNAND. (can be USA, EUR, JPN, KOR, CHN, TWN, or UNK for unknown)
  • SERIAL - the serial of the console's SysNAND, not including Check Digit. (i.e. CW13701547)
  • GM9OUT - the standard output path (i.e. 0:/gm9/out)
  • CURRDIR - the directory the script is running from (i.e. 0:/gm9/scripts)
  • HAX - the exploit the system is running from (can be ntrboot, sighax, a9lh, or (empty, would be ""))
  • ONTYPE (stands for Old/NewTYPE) - the console type. (O3DS or N3DS)
  • RDTYPE (stands for Retail/DevTYPE) - the unit type. (retail or devkit)
  • SYSID0 - ID0 of SysNAND.
  • EMUID0 - ID0 of EmuNAND (if available).
  • TIMESTAMP - the current time in hhmmss format (based on RTC).
  • DATESTAMP - the current date in YYMMDD format (based on RTC).
Clone this wiki locally