Support Forums

Powershell Studio 2015 EXE Package Issue

Use this forum to ask questions 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.
User avatar
sbalke7270
Posts: 3
Joined: Tue Jan 26, 2016 3:41 pm

Powershell Studio 2015 EXE Package Issue

Postby sbalke7270 » Thu Jan 28, 2016 6:54 am

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.
User avatar
DevinL
Site Admin
Posts: 731
Joined: Mon Aug 17, 2015 2:25 pm

Re: Powershell Studio 2015 EXE Package Issue

Postby DevinL » Thu Jan 28, 2016 11:49 am

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:

Get-Service | Where-Object {$_.Status -eq "Running"}
 
# If running in the console, wait for input before closing.
if($Host.Name -eq "PrimalScriptHostImplementation")
{
Write-Output "Press any key to continue..."
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null
}
DevinL
SAPIEN Technologies, Inc.
User avatar
sbalke7270
Posts: 3
Joined: Tue Jan 26, 2016 3:41 pm

Re: Powershell Studio 2015 EXE Package Issue

Postby sbalke7270 » Thu Jan 28, 2016 12:47 pm

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.
User avatar
DevinL
Site Admin
Posts: 731
Joined: Mon Aug 17, 2015 2:25 pm

Re: Powershell Studio 2015 EXE Package Issue

Postby DevinL » Thu Jan 28, 2016 1:04 pm

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.

Return to “Trial Software Questions”

Who is online

Users browsing this forum: No registered users and 4 guests