Quantcast
Channel: SAPIEN Forums
Viewing all articles
Browse latest Browse all 546

PowerShell GUIs • Re: PowerShell GUI but with silent mode, output in PS Window

$
0
0
I don't know about returning output to a console from a project packaged with the Windows Forms engine, but I did a project for work where I wanted to provide the same tool through a GUI application as well as from the command line. What I did was this:
  • 1) I included in the project a powershell wrapper script to call the cli version of the tool. This gives the users the added convenience of parameter name tab completion, etc.

    2) Set the wrapper script Build property to Exclude so it's not included when you build the project

    3) Built the project twice - once with the Windows Forms script host, and once with the Command line script host (adding 'cli' to the end of the output file)

    4) Finally, for the installer, include both of your packaged executables (the windows forms and the command line exe's) as well as the powershell wrapper script for the cli version.
One other note - I added an If ($sapienhost.gettype().module.scopename -like "PoshExeHostCmd*") statement in the project code (in startup.pss) so it can detect if it is running using the command line or the windows forms script host so I could make it behave appropriately in either case.

I know this isn't the specific answer you're looking for, but it works out great for my project.

Statistics: Posted by dwknight — Thu Dec 05, 2024 1:04 pm



Viewing all articles
Browse latest Browse all 546

Trending Articles