# claude --desktop "can't run non-interactively" from a script: open claude://resume instead

> claude --desktop exits 1 when its output is redirected, from a script or hook: "can't run non-interactively (... or redirected output)". Opening claude://resume?session=<id> via rundll32 switched the app to that chat. Measured by AO, 2026-10-09 to 10-17.

`claude --desktop --resume <session id>` opens a Claude Code session in the Claude desktop app. Typed in a terminal, it works. Run from a script, a scheduled task or a hook, it stops at once:

```
--desktop opens the Claude Desktop app and can't run non-interactively (`--print`, `--sdk-url`, `--init-only`, or redirected output).
```

It exits with status 1 and opens nothing. "Redirected output" is the part that catches people: any program that reads the command's output, as almost every script runner does, counts. The CLI reference lists what `--desktop` cannot be combined with, but not this.

**How AO hit it.** AO's AIsle plugin has a Reopen button that brings a folder's chat back after a restart. Version 0.3.8 ran `claude --desktop --resume <id>` from a Claude Code hooks module. Such a module captures the output of every command it runs, so the first live press failed with the message above. Claude Code 2.1.299 still refuses the same way, and the check runs before anything opens.

**The fix: open the app's link yourself.** `claude --desktop` hands a link to the operating system, and the docs show which one in an error message: `claude://resume?session=<session id>`. Open that link directly. On Windows:

```
rundll32 url.dll,FileProtocolHandler "claude://resume?session=<session id>"
```

That switched the desktop app to the existing chat and made no copy of it. The same in Node.js, with the check AO's plugin 0.3.9 uses so that only a session id gets into the link:

```
import { spawn } from 'node:child_process';

function openInDesktop(sessionId) {
  if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId)) return false;
  const link = `claude://resume?session=${sessionId}`;
  const [cmd, ...args] = process.platform === 'win32'
    ? [`${process.env.SystemRoot || 'C:\\Windows'}\\System32\\rundll32.exe`, 'url.dll,FileProtocolHandler', link]
    : ['open', link];
  spawn(cmd, args, { stdio: 'ignore', detached: true }).unref();
  return true;
}
```

The session id is the one `/status` shows, and the name of the session's transcript file under `~/.claude/projects/`.

**Not tested.** Opening a chat with the Node.js function as written: a dry run printed the same command the plugin runs, and refused an id that is not a UUID, but it was not pointed at the app. macOS: the `open` branch follows the docs' own error message, but AO ran the link only on Windows 11. Whether redirecting stdin alone, with output on a terminal, also triggers the refusal. Opening a session that is still running in another terminal. The link is the app's own, not a documented interface, so a future app version may change it.

## Evidence
- With stdin and stdout redirected, `claude --desktop --resume <session id>` printed "--desktop opens the Claude Desktop app and can't run non-interactively (`--print`, `--sdk-url`, `--init-only`, or redirected output)." and exited 1, on Claude Code 2.1.286 (2026-10-09) and 2.1.299 (2026-10-17, Windows 11)
- In 2.1.299 that check runs before the app is opened, so nothing happens on screen (read from the 2.1.299 binary, 2026-10-17)
- A command run by a Claude Code hooks module always has its output captured, so a "reopen this chat" button built on `claude --desktop` failed on its first live press (AO's AIsle plugin 0.3.8, 2026-10-09)
- `rundll32 url.dll,FileProtocolHandler claude://resume?session=<id>` switched the desktop app to that existing chat and made no copy (seen by AO, 2026-10-09); plugin 0.3.9 opens chats this way, and after a Windows restart it brought a chat back on 2026-10-10
- The docs show `claude://resume?session=<session-id>` only inside an error message, as the link Claude Code itself hands to `open` on macOS and `rundll32` on Windows (Errors reference, read 2026-10-17)

Sources:
- Claude Code docs — CLI reference, --desktop — https://code.claude.com/docs/en/cli-reference#cli-flags (accessed 2026-10-17)
- Claude Code docs — Desktop, "Coming from the CLI" — https://code.claude.com/docs/en/desktop#coming-from-the-cli (accessed 2026-10-17)
- Claude Code docs — Errors, "Couldn't open Claude Desktop" — https://code.claude.com/docs/en/errors#couldnt-open-claude-desktop (accessed 2026-10-17)

## Related
- [Claude Code plugins not auto-updating in the desktop app: it sets DISABLE_AUTOUPDATER=1](https://abstractobjective.dev/ai/claude-desktop-app-skips-plugin-auto-update/index.md)
- [Claude Code hooks slow on Windows: each program a hook starts cost AO 43 to 203 ms](https://abstractobjective.dev/ai/claude-code-hooks-on-windows-cost-per-program/index.md)
- [MCP server instructions cut off in the Claude desktop app: 2,048 characters, not 4,096](https://abstractobjective.dev/ai/claude-code-mcp-server-instructions-cut-2048-desktop-app/index.md)

---
Published 2026-10-17 · claude-code, claude-desktop, windows · AO — Abstract Objective · https://abstractobjective.dev/ai/claude-desktop-cant-run-non-interactively-redirected-output/

The index of the whole site, for agents: https://abstractobjective.dev/llms.txt
