Ok sounds strange but I am passing a command line to my gui utility to continue processing if a reboot happens during use.
so I have code like below in the form load
$p1 is the command line
if ($p1.Length -gt 6)
{
$global:p1CfgFile = Split-Path -leaf $P1
$Script:outputFile = $p1CfgFile
add-Content -Path "c:\softdist\appinstaller2\$outputfile-$Date.log" -Value "Continuing Installs via Run Key of CFG File --> $P1CfgFile " -Force
$Status = "Continuing"
#$form_main.Show this didn't help
$buttonStartsInstalls.Enabled = $true
$buttonStartsInstalls.PerformClick()
}
so I want to show my form but run the code from that click event. how can I force the form to show I thought fom.show would do the trick
thanks
how to show main form if the form_load is not complted
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- ocsscott6969
- Posts: 48
- Last visit: Tue Dec 05, 2023 10:04 am
Re: how to show main form if the form_load is not complted
$form.Show() cannot be used in PowerShell. You can only use "ShowDialog()"
What you are trying to do cannot be done. You cannot split a command over many lines like you are doing.
If you are trying to restart a form after a reboot then it is more sensible to set a flag in the registry and check it each time the form is opened.
What you are trying to do cannot be done. You cannot split a command over many lines like you are doing.
If you are trying to restart a form after a reboot then it is more sensible to set a flag in the registry and check it each time the form is opened.
- ocsscott6969
- Posts: 48
- Last visit: Tue Dec 05, 2023 10:04 am
Re: how to show main form if the form_load is not complted
I am not sure what you mean when you say I cant split a command over many lines can you be specific which lines do you mean?
and for the other part I can use showdialog to show my main form inside the form load event?
its so hard to explain these things in email vs talking not sure I am explaining what I am trying to do correctly.
and for the other part I can use showdialog to show my main form inside the form load event?
its so hard to explain these things in email vs talking not sure I am explaining what I am trying to do correctly.
Re: how to show main form if the form_load is not complted
In PowerShell with PS Studio all forms are displayed using ShowDialog. This is coded for you automatically. If the main form starts a child form the main form cannot be made current until the child is closed.
I cannot understand what you are trying to do or what your issue is. If the system reboots there will be no forms. The form will have to be restarted. Adding code cannot protect you from a reboot.
I cannot understand what you are trying to do or what your issue is. If the system reboots there will be no forms. The form will have to be restarted. Adding code cannot protect you from a reboot.
Re: how to show main form if the form_load is not complted
The following command is on multiple lines and will have an extra line break added to the file.
add-Content -Path "c:\softdist\appinstaller2\$outputfile-$Date.log" -Value "Continuing Installs via Run Key of CFG File --> $P1CfgFile " -Force
To avoid this we can:
$msg = "Continuing Installs via Run Key of CFG File --> $P1CfgFile "
$msg | Add-Content c:\softdist\appinstaller2\$outputfile-$Date.log"
As I noted above, a form cannot be continued. A workflow can be continued if it is designed correctly.
add-Content -Path "c:\softdist\appinstaller2\$outputfile-$Date.log" -Value "Continuing Installs via Run Key of CFG File --> $P1CfgFile " -Force
To avoid this we can:
$msg = "Continuing Installs via Run Key of CFG File --> $P1CfgFile "
$msg | Add-Content c:\softdist\appinstaller2\$outputfile-$Date.log"
As I noted above, a form cannot be continued. A workflow can be continued if it is designed correctly.
- ocsscott6969
- Posts: 48
- Last visit: Tue Dec 05, 2023 10:04 am
Re: how to show main form if the form_load is not complted
That long line is just how it copy/pasted it is one line in the code editor.
The showdialog worked like a charm
thanks
The showdialog worked like a charm
thanks