Author Posts

July 24, 2018 at 10:43 pm

Hi,
I've built a GUI form (called FORM1) in PowerShell that has several buttons to launch several applications.
Most buttons launch .exe's but in one case I'd like to launch another .ps1 that displays another gui interface (called FORM2).
The trouble is, when I launch the .ps1,(FORM2) it disables the other buttons on the first panel (FORM1) until I close FORM1.
I'd like to know how to code it so FORM2 is independent of FORM1.
I've tried using "Start-Process -File C:\users\app2.ps1" and "& C:\users\app2.ps1"
I can't see any parameters where the app2.ps1 would launch in a separate instance.

Any ideas?

July 25, 2018 at 2:25 am

This is an overly broad request and not really a PS issue.

You don't show any of your code and what you'd expect to happen.

Why are you using Start-Process to run a .ps1 file, from a PS GUI app, that is already running in a host operation?

Start-Process, by design, is to start a completely separate operation/instance not within the same running instance.

All of your separate .ps1 files, should be functions in your from code to call. .EXE/.MSI, etc., are called with Start-Process or other options.

So, this is an issue with how you are trying to go thru this, not a PS issue. It's a human logic one. If your in a multi-form GUI, once you open the child the parent will lose focus (until you close the child), it's supposed to. Again, not a PS issue but an understanding of how Multi-form GUIs work.

There are a lot of YouTube videos that take you through this sort of thing as well as GUI Design blogs / articles to assist. Just search for them.

This article is using a commercial tool (a really good one for this stuff), but the concept is the same if you are designing GUIs manually.
https://info.sapien.com/index.php/guis/gui-scripting/write-a-multi-form-powershell-gui-app