![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest
Posts: n/a
| Hide console and capture output from script? I'm trying to figure out how to go about launching a command-line exe from a Powershell script while capturing its output and not showing the command window. I currently have: $result = (Invoke-Expression "c:\myconsoleapp.exe -param $myparam") "The result is: $result" While this works, a new window pops up for myconsoleapp.exe. Is there a way to prevent this and just capture the out? |
| | #2 (permalink) |
| Guest
Posts: n/a
| RE: Hide console and capture output from script? Not sure you can - you are invoking cmd.exe to run your console app & I can't see a way to run it without the window -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "Brian Vallelunga" wrote: > I'm trying to figure out how to go about launching a command-line exe > from a Powershell script while capturing its output and not showing > the command window. > > I currently have: > > $result = (Invoke-Expression "c:\myconsoleapp.exe -param $myparam") > "The result is: $result" > > > While this works, a new window pops up for myconsoleapp.exe. Is there > a way to prevent this and just capture the out? > > |
| | #3 (permalink) |
| Guest
Posts: n/a
| Re: Hide console and capture output from script? Maybe you could create a runspace and run the exe from it and get the output. -- William Stacey [C# MVP] "Brian Vallelunga" <brian@vallelunga.com> wrote in message news:1175559433.206504.12920@n76g2000hsh.googlegroups.com... | I'm trying to figure out how to go about launching a command-line exe | from a Powershell script while capturing its output and not showing | the command window. | | I currently have: | | $result = (Invoke-Expression "c:\myconsoleapp.exe -param $myparam") | "The result is: $result" | | | While this works, a new window pops up for myconsoleapp.exe. Is there | a way to prevent this and just capture the out? | |
| | #4 (permalink) |
| Guest
Posts: n/a
| Re: Hide console and capture output from script? Unless myconsoleapp.exe explicitly creates a new console window, it should just inherit the current console window. Does this behavior happen only from PowerShell? "Brian Vallelunga" <brian@vallelunga.com> wrote in message news:1175559433.206504.12920@n76g2000hsh.googlegroups.com... > I'm trying to figure out how to go about launching a command-line exe > from a Powershell script while capturing its output and not showing > the command window. > > I currently have: > > $result = (Invoke-Expression "c:\myconsoleapp.exe -param $myparam") > "The result is: $result" > > > While this works, a new window pops up for myconsoleapp.exe. Is there > a way to prevent this and just capture the out? > |
| | #5 (permalink) |
| Guest
Posts: n/a
| Re: Hide console and capture output from script? On Apr 3, 11:35 am, "Marcel J. Ortiz [MSFT]" <mos...@online.microsoft.com> wrote: > Unless myconsoleapp.exe explicitly creates a new console window, it should > just inherit the current console window. Does this behavior happen only > from PowerShell? > > "Brian Vallelunga" <b...@vallelunga.com> wrote in message > > news:1175559433.206504.12920@n76g2000hsh.googlegroups.com... > > > > > I'm trying to figure out how to go about launching a command-line exe > > from a Powershell script while capturing its output and not showing > > the command window. > > > I currently have: > > > $result = (Invoke-Expression "c:\myconsoleapp.exe -param $myparam") > > "The result is: $result" > > > While this works, a new window pops up for myconsoleapp.exe. Is there > > a way to prevent this and just capture the out?- Hide quoted text - > > - Show quoted text - If I just launch a shell and type in the program name and parameters neither CMD nor Powershell launch a new window. It only occurs when launched via Invoke-Expression in my script that it launches a new window. |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem grabbing console output | Justin Rich | PowerShell | 1 | 07-07-2008 07:51 AM |
| capture command and its output | hugh | PowerShell | 1 | 02-16-2008 08:40 AM |
| output of long lines gets split in PS console | Frank | PowerShell | 5 | 05-17-2007 02:52 PM |
| Writing to host in functions and cmdlets - how to capture this output | Keith Hill [MVP] | PowerShell | 1 | 12-30-2006 03:54 PM |
| function return values, console output | =?Utf-8?B?ZnV6enkzMzM=?= | PowerShell | 3 | 08-22-2006 07:29 AM |