not getting output from msgbox
Posted: 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
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