Skip to content

Create <powershell> action #187

@end2endzone

Description

@end2endzone

Is your feature request related to a problem? Please describe.
There is no quick way to define a run a powershell command from ShellAnything.
The main benefit would be to be easily be able to simplify commands that needs to go through cmd.exe. For example,

<actions>
  <exec path="${env.ComSpec}" basedir="${env.TEMP}" arguments="/k &quot;&quot;${ffmpeg.install_directory}\bin\ffprobe.exe&quot; -v verbose -hide_banner -show_streams -show_format -print_format json -i &quot;${selection.path}&quot;&quot;" />
</actions>

(notice the whole command is escaped twice and wrapped in double-quotes).

As a restriction, this action should always "open a new process" to run the command. Running the powershell command within ShellAnything's process (explorer.exe) would force .NET runtime to load in explorer.exe which is not recommanded.

Describe the solution you'd like
A quick way to define an action that runs a powershell command:

<actions>
  <powershell command="Write-Host (10+27)"/>
</actions>

Describe alternatives you've considered
N/A

Additional context
There are security concerns about sending the command up to powershell without manipulation.
One way would be to run the following:

  1. Plan on launching powershell.exe directly, or by running a shell command that starts with "powershell".
  2. When lauching the process, define the environment variable SA_POWERSHELL_COMMAND set as action's command property.
    For example: Write-Host (10+27).
  3. Launch powershell with the following: powershell -Command "Invoke-Expression $env:PS_COMMAND".
  4. The command above would print 37 on the console and then exit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions