Add a script tool

To add a script tool to a toolbox, complete the following steps:

  1. Right-click the toolbox or toolset in which you want to create the script tool and click New > Script.
    1. For Name, enter the name for the script tool.

      The name is used when the script tool is run from Python. You cannot have a space in the name.

    2. For Label, enter the label for the script tool.

      The label is the display name for the script tool (as shown in the Geoprocessing pane) and can contain spaces.

    3. If you have already created a script, browse to the location of your script and select it. If your script does not already exist, you can skip adding a script file and add it later by changing the properties of the script tool.
    4. Optionally, if you have provided a script and want to embed it (that is, have the contents of your script stored internally with the toolbox), check the Import script check box.
    5. Optionally, if you have previously embedded a script, you can choose to provide a password to restrict access to the source code by checking the Set password check box. On the Set Password dialog box, enter your new password twice and click OK.
    6. Optionally, uncheck the Store tool with relative path check box to store absolute paths.
  2. Click Parameters.
    The dialog box appears as follows:
    Define the script tool parameters.
    1. Define the tool parameters in this panel.
      Almost all tools have input parameters, and all tools must have an output parameter to be used in ModelBuilder.

      Learn more about setting parameters

  3. Optionally, click Validation.

    Validation is everything that happens before a tool's OK button is clicked. When creating custom tools, validation allows you to customize how parameters respond and interact to values and each other. Validation is performed with a block of Python code that can be used to give additional control over parameter behavior. For more information, see Customizing script tool behavior.

  4. Click OK.

Your script tool is added to the toolbox. You can open and use it like any other geoprocessing tool. You can change any of its properties, including parameters, by right-clicking the script tool and clicking Properties.

関連トピック