Add a Script action type for running inline PowerShell - #68
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
.ps1file:-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).UseShellExecute=false+CreateNoWindow). A fresh Script action defaults to hidden; once a script is written, the hidden choice is preserved across type toggles.powershell.exeand is editable (e.g.pwsh.exefor PowerShell 7)."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
Opentype (which shell-executes a target and can't run a script silently):Scripttakes a script you write and runs it through PowerShell with a hidden console.Notes
mainafter Rename the Shell action type to Open #67 (theShell→Openrename);Scriptis added alongsideOpen.ScriptandRunHiddenare new serializedPieActionfields; old settings files load fine (missing values default), andNormalizeAfterLoadhandles the newScriptfield.