Start .ps1 from a powershell gui form

Welcome Forums General PowerShell Q&A Start .ps1 from a powershell gui form

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
3 months, 3 weeks ago.

  • Author
    Posts
  • #105134
    Jim

    Participant
    Points: 0
    Rank: Member

    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?

  • #105143

    Participant
    Points: 213
    Helping Hand
    Rank: Participant

    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

The topic ‘Start .ps1 from a powershell gui form’ is closed to new replies.