Page 1 of 1

Powershell Studio 2015 EXE Package Issue

Posted: Thu Jan 28, 2016 5:54 am
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.

Re: Powershell Studio 2015 EXE Package Issue

Posted: Thu Jan 28, 2016 10:49 am
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. }

Re: Powershell Studio 2015 EXE Package Issue

Posted: Thu Jan 28, 2016 11:47 am
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.

Re: Powershell Studio 2015 EXE Package Issue

Posted: Thu Jan 28, 2016 12:04 pm
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.