Open Powershell CMD Window from GUI

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 8 years and 1 month 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
User avatar
derhoeppi
Posts: 34
Last visit: Mon Nov 28, 2022 8:48 am

Open Powershell CMD Window from GUI

Post by derhoeppi »

Hi,
is it possible to open a powershell window by clicking a button. The powershell window should be in the same session like the GUI. With tith one i would to migrate my scripts in one Powershell GUI.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Open Powershell CMD Window from GUI

Post by jvierra »

Currently there is no straight-forward way todo this. It can be done with advanced programming techniques.

You can display a textbox that you can type into then process the text as a command.

It you type the following into a textbox:

Get-Content c:\windows

Then process it like this:

$files=Invoke-Expression $textbox1.Text

The code will be executed.
User avatar
derhoeppi
Posts: 34
Last visit: Mon Nov 28, 2022 8:48 am

Re: Open Powershell CMD Window from GUI

Post by derhoeppi »

Hi,

thanks for your answer. You wrote from advanced programming technology. Is your example with the textbox a advance programming technic?

Is it possible to open a separte Powershell session and transfer some variables to the new session? If i open a new session - i have to add all modules a second time (with the same time for loading)?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Open Powershell CMD Window from GUI

Post by jvierra »

derhoeppi wrote:Hi,

thanks for your answer. You wrote from advanced programming technology. Is your example with the textbox a advance programming technic?

Is it possible to open a separte Powershell session and transfer some variables to the new session? If i open a new session - i have to add all modules a second time (with the same time for loading)?
No, but it is not exactly what you asked for.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: Open Powershell CMD Window from GUI

Post by dan.potter »

derhoeppi wrote:Hi,
is it possible to open a powershell window by clicking a button. The powershell window should be in the same session like the GUI. With tith one i would to migrate my scripts in one Powershell GUI.

Why would you want to do this?
This topic is 8 years and 1 month 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