not getting output from msgbox

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
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.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
ocsscott
Posts: 47
Joined: Thu Dec 17, 2015 7:24 am

not getting output from msgbox

Post by ocsscott » Mon Jul 15, 2019 8:22 am

PSS 019 current build. win 10 64bit

code works in PSS but once compiled I am not getting the message boxes not am I getting the correct path of the exe that is running

Ive tried compiling as windows form and application neither seems to work. (which is the better option for a windows form and msgboxes?

any ideas on both the pth not showing once compiled and some message boxes not happening?

Param (
[string]$p1
)

function Show-MsgBox
{

[CmdletBinding()]
param (
[Parameter(Position = 0, Mandatory = $true)]
[string]$Prompt,
[Parameter(Position = 1, Mandatory = $false)]
[string]$Title = "",
[Parameter(Position = 2, Mandatory = $false)]
[ValidateSet("Information", "Question", "Critical", "Exclamation")]
[string]$Icon = "Information",
[Parameter(Position = 3, Mandatory = $false)]
[ValidateSet("OKOnly", "OKCancel", "AbortRetryIgnore", "YesNoCancel", "YesNo", "RetryCancel")]
[string]$BoxType = "OkOnly",
[Parameter(Position = 4, Mandatory = $false)]
[ValidateSet(1, 2, 3)]
[int]$DefaultButton = 1
)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic") | Out-Null
switch ($Icon)
{
"Question" { $vb_icon = [microsoft.visualbasic.msgboxstyle]::Question }
"Critical" { $vb_icon = [microsoft.visualbasic.msgboxstyle]::Critical }
"Exclamation" { $vb_icon = [microsoft.visualbasic.msgboxstyle]::Exclamation }
"Information" { $vb_icon = [microsoft.visualbasic.msgboxstyle]::Information }
}
switch ($BoxType)
{
"OKOnly" { $vb_box = [microsoft.visualbasic.msgboxstyle]::OKOnly }
"OKCancel" { $vb_box = [microsoft.visualbasic.msgboxstyle]::OkCancel }
"AbortRetryIgnore" { $vb_box = [microsoft.visualbasic.msgboxstyle]::AbortRetryIgnore }
"YesNoCancel" { $vb_box = [microsoft.visualbasic.msgboxstyle]::YesNoCancel }
"YesNo" { $vb_box = [microsoft.visualbasic.msgboxstyle]::YesNo }
"RetryCancel" { $vb_box = [microsoft.visualbasic.msgboxstyle]::RetryCancel }
}
switch ($Defaultbutton)
{
1 { $vb_defaultbutton = [microsoft.visualbasic.msgboxstyle]::DefaultButton1 }
2 { $vb_defaultbutton = [microsoft.visualbasic.msgboxstyle]::DefaultButton2 }
3 { $vb_defaultbutton = [microsoft.visualbasic.msgboxstyle]::DefaultButton3 }
}
$popuptype = $vb_icon -bor $vb_box -bor $vb_defaultbutton
$ans = [Microsoft.VisualBasic.Interaction]::MsgBox($prompt, $popuptype, $title)
return $ans
} #end function

Show-MsgBox -Title "test1" -Prompt "test1" -Icon Critical -BoxType OKOnly
$A = $PSScriptRoot
$global:LocalPath = $A
Show-MsgBox -Title "test2" -Prompt "$A" -Icon Critical -BoxType OKOnly
Show-MsgBox -Title "localPath" -Prompt "$global:LocalPath" -Icon Critical -BoxType OKOnly

$B = $PSCommandPath
$global:LocalPath2 = $B
Show-MsgBox -title "localPath" -Icon Critical -BoxType OKOnly -Prompt "$global:LocalPath2"

$form_main_Load={
#TODO: Initialize Form Controls here

#$global:Debug = $true

$PSV = $psversiontable.psversion.tostring()

#$PSV = "3.2"

$RemoteVer = "0.0.0"
$AppVer = "2.3.0"

$RemoteVer = get-content "\\xxx\AppInstallerVerCheck\version.txt"

If ($PSV -lt 5.0)
{
Show-MsgBox -title "Error - PowerShell Version 5 Required!!" -Icon Critical -BoxType OKOnly -Prompt "Please Install Powershell 5 From the Powershell Folder on the thumbdrive. `n `nREBOOT and then run App Installer again!"

$form_main.close()
return
}

$A = $PSScriptRoot
$global:LocalPath = $A
Show-MsgBox -title "localPath" -Icon Critical -BoxType OKOnly -Prompt "$global:LocalPath"

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:
32 or 64 bit version of product:
Operating system:
32 or 64 bit OS:

*** Please add details and screenshots as needed below. ***

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

User avatar
Alexander Riedel
Posts: 7129
Joined: Tue May 29, 2007 4:43 pm

Re: not getting output from msgbox

Post by Alexander Riedel » Mon Jul 15, 2019 11:20 am

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:
32 or 64 bit version of product:
Operating system:
32 or 64 bit OS:
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
ocsscott
Posts: 47
Joined: Thu Dec 17, 2015 7:24 am

Re: not getting output from msgbox

Post by ocsscott » Mon Jul 15, 2019 11:29 am

5.6.165 64 bit on win 10 64bit

User avatar
brittneyr
Site Admin
Posts: 243
Joined: Thu Jun 01, 2017 7:20 am

Re: not getting output from msgbox

Post by brittneyr » Mon Jul 15, 2019 12:57 pm

When you run the build and run your exe, is there any output in the Tools Output window?
SPS_ToolsOutputw.png
SPS_ToolsOutputw.png (132.41 KiB) Viewed 1792 times
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
ocsscott
Posts: 47
Joined: Thu Dec 17, 2015 7:24 am

Re: not getting output from msgbox

Post by ocsscott » Mon Jul 15, 2019 1:02 pm

no errors see below.

should I be compiling as windows, windows forms or windows applications I am having a hard time understanding the difference

> Package 'P:\!!PowerShell_GUI_Projects\AppInstaller2.3\AppInstallerMain.psf'
>> Building (AppInstallerMain.psf) ...
SAPIEN Package and Deploy Tool 4.1 (c) 2005 - 2019 SAPIEN Technologies, Inc.

------ Build started: AI2, Configuration: x86 ------
Packaging with SAPIEN PowerShell V5 Host (Windows) Win32
Adding P:\!!PowerShell_GUI_Projects\AppInstaller2.3\AppInstallerMain.Package.ps1
Writing scripts to bin\x86\AI2.exe
Embedding default manifest...
Package completed


>> Completed

User avatar
Alexander Riedel
Posts: 7129
Joined: Tue May 29, 2007 4:43 pm

Re: not getting output from msgbox

Post by Alexander Riedel » Mon Jul 15, 2019 1:27 pm

It really depends on what you are doing.

In a nutshell:

Windows is a generic Windows app and all output (e.g. Write-Host) is directed to a message box.
Windows Forms eats all generic powershell output from Write-host, write-output, out-* etc. All output must be through form elements or message boxes.
Windows Application creates a window where all console output is piped to a windows text box.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
ocsscott
Posts: 47
Joined: Thu Dec 17, 2015 7:24 am

Re: not getting output from msgbox

Post by ocsscott » Mon Jul 15, 2019 1:32 pm

all my output is on the windows form itself or via the show-messagebox code I attached. what is best for that scenario?

but for my original questions any idea why the message boxes are not showing up compiled but work perfect inside pss?

and the same for the path issue it always shows in PSS but not working compiled?

any chance I could call/contact someone directly.. a 5 min screen share would probably solve the whole thing ;)

User avatar
brittneyr
Site Admin
Posts: 243
Joined: Thu Jun 01, 2017 7:20 am

Re: not getting output from msgbox

Post by brittneyr » Mon Jul 15, 2019 3:17 pm

If all of your output is in a form or message boxes, you should use a Windows Form Engine.
With the code you have provided, I have it running and showing the messages just fine when packaged with Window Forms V5 engine:
SPS-packager.png
SPS-packager.png (58.53 KiB) Viewed 1744 times
If you run the directly from its folder, does it still not work?
Regarding the path issue, there was a known issue in the packager with $PSScriptRoot. Please try the latest build (5.6.166) of PowerShell Studio.
We do not provide Call support.
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
ocsscott
Posts: 47
Joined: Thu Dec 17, 2015 7:24 am

Re: not getting output from msgbox

Post by ocsscott » Tue Jul 16, 2019 6:42 am

The MSGbox was a issue when the path was black it failed that's why I didn't get all of them. I am compiling as windows forms

I Upgraded to .166 but still get the Issue. In the debugger all my path varialbes are correct when running the compiled exe they are blank. code and screenshots below

1)
$A = $PSScriptRoot
$global:LocalPath = $A
Show-MsgBox -Title "test2" -Prompt "* $A" -Icon Critical -BoxType OKOnly

2)
$B = $PSCommandPath
$global:LocalPath2 = $B
Show-MsgBox -title "cmdPath" -Icon Critical -BoxType OKOnly -Prompt "* $global:LocalPath2"

3)
$C = Get-Location
$global:getLocalPath = $C.path.ToString()
Show-MsgBox -title "getlocalPath" -Icon Critical -BoxType OKOnly -Prompt "* $global:getLocalPath"

see word doc for test result but basically I don't get data from $PSScriptRoot and $PSCommandPath from the compiled exe but its perfect in the debugger

$C = Get-Location
$global:getLocalPath = $C.path.ToString()

works the same in both but I get Microsoft.powershell.core.filesystem: appended to the beginning of the path

Thanks
TestResults.JPG
TestResults.JPG (40.72 KiB) Viewed 1663 times

User avatar
brittneyr
Site Admin
Posts: 243
Joined: Thu Jun 01, 2017 7:20 am

Re: not getting output from msgbox

Post by brittneyr » Tue Jul 16, 2019 9:36 am

So far I have been able to reproduce the issue you are having with 'Microsoft.PowerShell.Core' being appended to the beginning of the path, but I'm able to get values from $PSScriptRoot and $PSCommandPath. We are currently look into this issue and will update you when we have more information. If there is any other details you can provide to help us recreate your issue?
Also, is this the complete script you are running?
Brittney Ryn
SAPIEN Technologies, Inc.