Skip to content

Add a Script action type for running inline PowerShell - #68

Merged
danielchalmers merged 1 commit into
mainfrom
script-action-type
Jul 17, 2026
Merged

Add a Script action type for running inline PowerShell#68
danielchalmers merged 1 commit into
mainfrom
script-action-type

Conversation

@danielchalmers

@danielchalmers danielchalmers commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Resolves #58.

Adds a new Script action type: write a multiline PowerShell script directly in the action editor and run it on click, with no separate .ps1 file:

  • The script body is passed to the interpreter via -NoProfile -ExecutionPolicy Bypass -EncodedCommand <base64>, where the Base64 is the UTF-16LE bytes of the script. This means multiline bodies, quotes, and newlines need no escaping and no temp file (nothing to clean up).
  • Runs hidden by default (UseShellExecute=false + CreateNoWindow). A fresh Script action defaults to hidden; once a script is written, the hidden choice is preserved across type toggles.
  • Interpreter defaults to powershell.exe and is editable (e.g. pwsh.exe for PowerShell 7).
  • Optional working directory. A blank script ("Script is empty") and an over-long script that would exceed the command-line limit ("Script is too long to run") surface clear messages through the existing tray notification path.

This differs from the Open type (which shell-executes a target and can't run a script silently): Script takes a script you write and runs it through PowerShell with a hidden console.

Notes

  • Branched off main after Rename the Shell action type to Open #67 (the ShellOpen rename); Script is added alongside Open.
  • Respects the existing invariant that actions never execute during tests, settings load, preview, or validation — only on a slice click.
  • Script and RunHidden are new serialized PieAction fields; old settings files load fine (missing values default), and NormalizeAfterLoad handles the new Script field.
image

Adds an ActionType.Script that runs a multiline PowerShell script written
directly in the action editor, with no separate script file. The body is
passed to the interpreter via -EncodedCommand (Base64 of the UTF-16LE bytes)
so multiline scripts, quotes, and newlines need no escaping and no temp file.

- Runs hidden by default (UseShellExecute=false + CreateNoWindow); a fresh
  Script action defaults to hidden while preserving the choice on type toggles.
- Interpreter defaults to powershell.exe and is editable (e.g. pwsh.exe).
- Optional working directory; blank script and over-long scripts surface clear
  errors through the existing tray notification path.

Resolves #58.
@danielchalmers
danielchalmers merged commit 7cdb257 into main Jul 17, 2026
1 check passed
@danielchalmers
danielchalmers deleted the script-action-type branch July 17, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New action type: run command/script

1 participant