How to create a form and select a powershell script from a drop and run the script

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
This topic is 3 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
johnson54937
Posts: 10
Last visit: Thu Sep 14, 2023 2:16 am

How to create a form and select a powershell script from a drop and run the script

Post by johnson54937 »

To help you better we need some information from you.

*** 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:Powershell studio 2020
32 or 64 bit version of product:64
Operating system:
32 or 64 bit OS:Win 10 Pro - 10.0.18363

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

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


I see in your 'help files' a step-by-step to create a form to select a ps1 file and run, getting the results in a text box...
How would you implement a 'drop down' object to allow user to select the file stored in a folder in the project..to run
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: How to create a form and select a powershell script from a drop and run the script

Post by Alexander Riedel »

[Topic moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to create a form and select a powershell script from a drop and run the script

Post by jvierra »

Hi - Sorry I missed this.
To do what you ask you would need to get the folders in question and store them in a drop down listbox. TO run the file you can use the "SelectedIndexChanged" event to obtain the value and run it.

The Info Center has examples of how to use ComboBoxes and ListBoxes.
This topic is 3 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked