Powershell Studio 2015 EXE Package Issue

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 8 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
sbalke7270
Posts: 3
Last visit: Mon Apr 10, 2017 6:39 am

Powershell Studio 2015 EXE Package Issue

Post by sbalke7270 »

Product, version and build: Powershell Studio 2015
32 or 64 bit version of product: 64 bit
Operating system: Windows 10 Pro / Windows 8.1 Pro
32 or 64 bit OS: both 64 bit

When I write a basic Powershell script and I try to turn that into an exe file in Powershell Studio 2015, the exe runs, but instantly closes. I also have a control in my script that says to wait for a key press before closing the window. I am very interested in purchasing this product and the ability to create the exe packages is a big selling point for me and for my company. We would like to be able to create Powershell tools that standard uses can just double click on and get certain information (like password expiration dates and such). The script I was trying is below, if that matters. I just need to know if there is something I'm doing wrong in Powershell Studio 2015. If I create a form, I can make that an exe and it works as expected.

Get-Service | ? {$_.Status -eq "Running"}

# If running in the console, wait for input before closing.
if ($Host.Name -eq "ConsoleHost")
{
Write-Host "Press any key to continue..."
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null
}


Thanks in advance,
Steve B.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Powershell Studio 2015 EXE Package Issue

Post by DevinL »

You were close however the packager host name is PrimalScriptHostImplementation. If you change your code to the following, you'll have the console window remain open without issue:
  1. Get-Service | Where-Object {$_.Status -eq "Running"}
  2.  
  3. # If running in the console, wait for input before closing.
  4. if($Host.Name -eq "PrimalScriptHostImplementation")
  5. {
  6.     Write-Output "Press any key to continue..."
  7.     $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null
  8. }
DevinL
SAPIEN Technologies, Inc.
User avatar
sbalke7270
Posts: 3
Last visit: Mon Apr 10, 2017 6:39 am

Re: Powershell Studio 2015 EXE Package Issue

Post by sbalke7270 »

Thanks DevinL! That did it for me. Now, I just need to figure a way to size the command window. I suppose, if I wanted to do that, I would just create a new form.

I do notice several different options for the platform when it comes to packaging the exe files. I'm using the Sapien Powershell v5 Host (Command Line) x64 option. I notice that if I select the Windows Forms option, I get no output. If I select the Windows option, I get my services listed one by one in separate windows that I have to click OK on before getting the next window.
DevinL
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: Powershell Studio 2015 EXE Package Issue

Post by DevinL »

Glad to hear that worked! As for the command window size I personally would recommend using an actual form and just placing the data you need on there so that it's much easier to customize in the long wrong.

As for the various platforms, you choose which one you want based on what you're building. For example anything that you just want to run in a Command Prompt you would select (Command Line) platforms or if you're building a form then you'd want the (Windows Forms) platform.
DevinL
SAPIEN Technologies, Inc.
This topic is 8 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.