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.
Locked
User avatar
derhoeppi
Posts: 34
Joined: Sun Apr 06, 2014 11:10 pm

Open Powershell CMD Window from GUI

Post by derhoeppi » Sat Feb 20, 2016 6:06 am

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: 13881
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Open Powershell CMD Window from GUI

Post by jvierra » Sat Feb 20, 2016 12:55 pm

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
Joined: Sun Apr 06, 2014 11:10 pm

Re: Open Powershell CMD Window from GUI

Post by derhoeppi » Sun Feb 21, 2016 4:27 am

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: 13881
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Open Powershell CMD Window from GUI

Post by jvierra » Sun Feb 21, 2016 4:48 am

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
Joined: Wed Oct 08, 2014 6:02 am

Re: Open Powershell CMD Window from GUI

Post by dan.potter » Mon Feb 22, 2016 8:03 am

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?

Locked