# Greenshot setup: upload with a command

How to set up Greenshot with hematite on Windows: download the script, add it as an external command, and each capture sent there goes up, its link copied.

[Greenshot](https://getgreenshot.org) is a free screenshot tool for Windows. Its **External Command** plugin runs a program with each capture and copies the first link it prints, which is what [hematite's upload script](https://hematite.gg/docs/uploaders/upload-script) does.

> **Warning: Greenshot 1.3.312 or later**
>
> Older versions let a capture's file name run commands through an external
> command (advisory
> [GHSA-7hvw-q8q5-gpmj](https://github.com/greenshot/greenshot/security/advisories/GHSA-7hvw-q8q5-gpmj),
> fixed in 1.3.311, and 1.3.312 fixed that fix). Update before you add one, and
> use the command below as it is: never through `cmd.exe /c`.

## Set it up

1. **Download the script.** In hematite, open [Settings → Uploaders](https://hematite.gg/settings/uploaders) and press **Download script** beside Greenshot. You get `hematite-upload.ps1`.
2. **Put it in place.** Make the folder `%LOCALAPPDATA%\hematite` (`C:\Users\nova\AppData\Local\hematite`) and move the script into it.
3. **Add the command.** Right-click Greenshot in the tray, choose **Configure external commands**, then **New**, and fill in:

   | Field     | What goes in it                                                                                                                    |
   | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
   | Name      | `hematite`                                                                                                                         |
   | Command   | `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe`                                                                      |
   | Arguments | `-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -File "%LOCALAPPDATA%\hematite\hematite-upload.ps1" "{0}"` |

   Greenshot puts the capture's path where `{0}` is. Press **OK**.

4. **Send a capture there.** After a capture, choose **hematite** among Greenshot's destinations. When it's up, the link is on your clipboard and Greenshot's notice links to it.

> **Warning: The script holds a token: keep it to yourself**
>
> Each download carries a new upload token, which is shown nowhere else. If the
> script gets out, remove the token and download a new one.

## When it fails

Greenshot's notice says the export failed, with the script's reason after it (when Greenshot's notices are on). [The upload script's guide](https://hematite.gg/docs/uploaders/upload-script#when-it-fails) lists what it says and what to do. Two refusals come from Greenshot itself:

- **"Filename contains potentially dangerous characters":** since 1.3.311, Greenshot refuses a capture whose path has `&`, `|`, `;`, `$`, a bracket, `<`, `>` or a quote in it, such as a capture saved under a window's title with "(1)" in it.
- **The command disappears:** Greenshot drops a command whose program it can't find when it starts. Check the **Command** field's path.

Greenshot 1.4, still in testing, has a plugin that reads [ShareX's config](https://hematite.gg/docs/uploaders/sharex); it isn't in its releases yet.

## Your upload tokens

The script's token lasts 90 days and counts toward your ten. It's listed as **Greenshot** on [Settings → Uploaders](https://hematite.gg/settings/uploaders) and in [Settings → Security](https://hematite.gg/settings/security). Remove it in either place and the script stops uploading; your other uploaders carry on.
