Group:  English: General ยป microsoft.public.windows.powershell
Thread: Native command redirection in Monad (MSH)

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Native command redirection in Monad (MSH)
Joey 13.07.2007 18:20:03
How do I redirect the output from the call of a native command to my own
PSHost application? I'm able to recieve the output from cmdlets but when
calling a native command like tf.exe a new window is spawned and the output
is not redirected. The

NotifyBeginApplication() method is being called in my host application, but
there are no parameters for me to hook onto the newly spawned process and
redirect it.

Here is an example:

$TFExecutablePath = "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE"

function DeleteWorkspace([String]$Name, [String]$TeamFoundationServerUrl)
{
$ErrorActionPreference = "stop"
# delete the workspace
& $TFExecutablePath\.\tf.exe workspace /delete $Name
/s:$TeamFoundationServerUrl /noprompt
# spit out the exit code
write-Host "ExitCode: $lastexitcode"
}

DeleteWorkspace "Test" "MyServer"

Since I'm running an external executable in this function I want to see the
output from the call to it and the following statement is what I'm expecting
to be redirected to my host application.

TF14061: The workspace Test;domain\user does not exist.


RE: Native command redirection in Monad (MSH)
dreeschkind 13.07.2007 19:00:00
Maybe this will help you: http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx

Also notice that Monad is now called Windows PowerShell.
http://en.wikipedia.org/wiki/Windows_PowerShell

--
greetings
dreeschkind

"Joey" wrote:

[Quoted Text]
> How do I redirect the output from the call of a native command to my own
> PSHost application? I'm able to recieve the output from cmdlets but when
> calling a native command like tf.exe a new window is spawned and the output
> is not redirected. The
>
> NotifyBeginApplication() method is being called in my host application, but
> there are no parameters for me to hook onto the newly spawned process and
> redirect it.
>
> Here is an example:
>
> $TFExecutablePath = "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE"
>
> function DeleteWorkspace([String]$Name, [String]$TeamFoundationServerUrl)
> {
> $ErrorActionPreference = "stop"
> # delete the workspace
> & $TFExecutablePath\.\tf.exe workspace /delete $Name
> /s:$TeamFoundationServerUrl /noprompt
> # spit out the exit code
> write-Host "ExitCode: $lastexitcode"
> }
>
> DeleteWorkspace "Test" "MyServer"
>
> Since I'm running an external executable in this function I want to see the
> output from the call to it and the following statement is what I'm expecting
> to be redirected to my host application.
>
> TF14061: The workspace Test;domain\user does not exist.
>
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net