Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Exit error in Pipeline

Closed Thread
 
Thread Tools Display Modes
Old 09-07-2007   #1 (permalink)
William Stacey [C# MVP]
Guest


 

Exit error in Pipeline

Seems if you have "exit" in script and run it in NestedPipeline, you get an
error you can't catch and it bogs the shell. Example:

string runScript = "echo hello;exit";
Pipeline p = Runspace.DefaultRunspace.CreateNestedPipeline(runScript,
false);
using(p)
{
// Exception: Cannot exit nested prompt because no nested prompts exist.
Collection<PSObject> results = p.Invoke(inputArray); // <= Error
}

What gives?
--
William Stacey [C# MVP]





Old 09-08-2007   #2 (permalink)
Oisin Grehan
Guest


 

Re: Exit error in Pipeline

On Sep 7, 7:17 pm, "William Stacey [C# MVP]"
<william.sta...@xxxxxx> wrote:
Quote:

> Seems if you have "exit" in script and run it in NestedPipeline, you get an
> error you can't catch and it bogs the shell. Example:
>
> string runScript = "echo hello;exit";
> Pipeline p = Runspace.DefaultRunspace.CreateNestedPipeline(runScript,
> false);
> using(p)
> {
> // Exception: Cannot exit nested prompt because no nested prompts exist.
> Collection<PSObject> results = p.Invoke(inputArray); // <= Error
>
> }
>
> What gives?
> --
> William Stacey [C# MVP]
A nested prompt is a nested RUNSPACE, not a nested pipeline.

- Oisin

Old 09-08-2007   #3 (permalink)
William Stacey [C# MVP]
Guest


 

Re: Exit error in Pipeline

? I was not talking about a nested prompt. The code shows nested pipeline.
The question is if you have "exit" in the script, it will throw an error you
can not catch and also screws the runspace to boot.

--
William Stacey [C# MVP]



"Oisin Grehan" <oising@xxxxxx> wrote in message
news:1189288496.214391.75060@xxxxxx
| On Sep 7, 7:17 pm, "William Stacey [C# MVP]"
| <william.sta...@xxxxxx> wrote:
| > Seems if you have "exit" in script and run it in NestedPipeline, you get
an
| > error you can't catch and it bogs the shell. Example:
| >
| > string runScript = "echo hello;exit";
| > Pipeline p = Runspace.DefaultRunspace.CreateNestedPipeline(runScript,
| > false);
| > using(p)
| > {
| > // Exception: Cannot exit nested prompt because no nested prompts
exist.
| > Collection<PSObject> results = p.Invoke(inputArray); // <= Error
| >
| > }
| >
| > What gives?
| > --
| > William Stacey [C# MVP]
|
| A nested prompt is a nested RUNSPACE, not a nested pipeline.
|
| - Oisin
|


Old 09-08-2007   #4 (permalink)
Oisin Grehan
Guest


 

Re: Exit error in Pipeline

On Sep 8, 7:18 pm, "William Stacey [C# MVP]"
<william.sta...@xxxxxx> wrote:
Quote:

> ? I was not talking about a nested prompt. The code shows nested pipeline.
> The question is if you have "exit" in the script, it will throw an error you
> can not catch and also screws the runspace to boot.
>
> --
> William Stacey [C# MVP]
>
> "Oisin Grehan" <ois...@xxxxxx> wrote in message
>
> news:1189288496.214391.75060@xxxxxx
> | On Sep 7, 7:17 pm, "William Stacey [C# MVP]"| <william.sta...@xxxxxx> wrote:
>
> | > Seems if you have "exit" in script and run it in NestedPipeline, you get
> an
> | > error you can't catch and it bogs the shell. Example:
> | >
> | > string runScript = "echo hello;exit";
> | > Pipeline p = Runspace.DefaultRunspace.CreateNestedPipeline(runScript,
> | > false);
> | > using(p)
> | > {
> | > // Exception: Cannot exit nested prompt because no nested prompts
> exist.
> | > Collection<PSObject> results = p.Invoke(inputArray); // <= Error
> | >
> | > }
> | >
> | > What gives?
> | > --
> | > William Stacey [C# MVP]
> |
> | A nested prompt is a nested RUNSPACE, not a nested pipeline.
> |
> | - Oisin
> |
Ah I see what you mean. I thought you deliberately put the exit there,
expecting it to exit the nested pipeline (thus implying to me that you
were thinking runspaces). Anyway, that's weird. Out of interest, is it
_really_ a nested pipeline for the current runspace? (meaning there is
a parent pipeline in process)

- Oisin

Old 09-09-2007   #5 (permalink)
William Stacey [C# MVP]
Guest


 

Re: Exit error in Pipeline

right. The current pipeline is the currently executing pipeline (in this
case current pipeline of the psh runspace that started this cmdlet). So
this cmdlet starts a nestedpipeline (as we can't start a new pipeline
because one is already running) to run the script. I think they could
probably special case "exit" in this case and just do a "return" to avoid
the error.

--
William Stacey [C# MVP]


"Oisin Grehan" <oising@xxxxxx> wrote in message
news:1189302642.558959.176070@xxxxxx
| On Sep 8, 7:18 pm, "William Stacey [C# MVP]"
| <william.sta...@xxxxxx> wrote:
| > ? I was not talking about a nested prompt. The code shows nested
pipeline.
| > The question is if you have "exit" in the script, it will throw an error
you
| > can not catch and also screws the runspace to boot.
| >
| > --
| > William Stacey [C# MVP]
| >
| > "Oisin Grehan" <ois...@xxxxxx> wrote in message
| >
| > news:1189288496.214391.75060@xxxxxx
| > | On Sep 7, 7:17 pm, "William Stacey [C# MVP]"|
<william.sta...@xxxxxx> wrote:
| >
| > | > Seems if you have "exit" in script and run it in NestedPipeline, you
get
| > an
| > | > error you can't catch and it bogs the shell. Example:
| > | >
| > | > string runScript = "echo hello;exit";
| > | > Pipeline p =
Runspace.DefaultRunspace.CreateNestedPipeline(runScript,
| > | > false);
| > | > using(p)
| > | > {
| > | > // Exception: Cannot exit nested prompt because no nested
prompts
| > exist.
| > | > Collection<PSObject> results = p.Invoke(inputArray); // <= Error
| > | >
| > | > }
| > | >
| > | > What gives?
| > | > --
| > | > William Stacey [C# MVP]
| > |
| > | A nested prompt is a nested RUNSPACE, not a nested pipeline.
| > |
| > | - Oisin
| > |
|
| Ah I see what you mean. I thought you deliberately put the exit there,
| expecting it to exit the nested pipeline (thus implying to me that you
| were thinking runspaces). Anyway, that's weird. Out of interest, is it
| _really_ a nested pipeline for the current runspace? (meaning there is
| a parent pipeline in process)
|
| - Oisin
|


Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
exit Justin Rich PowerShell 0 07-29-2008 08:41 AM
.NET error on boot up, failure to exit windows Stukie Vista networking & sharing 0 05-06-2008 06:34 PM
Using the $_ pipeline with WMI Larry R PowerShell 2 04-27-2007 09:27 AM
delete on exit emfd6100 Vista mail 1 02-23-2007 02:49 AM
.NET 1.1 exe remains in-use after exit SYNC/Anang Vista networking & sharing 4 05-30-2006 01:49 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50