Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - New Window vs Inline

Reply
 
Old 06-18-2008   #1 (permalink)
Michael Elsdörfer


 
 

New Window vs Inline

I'm not quite unterstanding when Powershell decides to open a new
command window vs. a command is run inline. For example:

PS> .\python-script.py

Opens a new window.

PS> python python-script.py

Does not. Is there a way to change this behaviour?

Michael

My System SpecsSystem Spec
Old 06-18-2008   #2 (permalink)
Jeff


 
 

Re: New Window vs Inline

On Jun 18, 11:17*am, Michael Elsdörfer <mich...@xxxxxx>
wrote:
Quote:

> I'm not quite unterstanding when Powershell decides to open a new
> command window vs. a command is run inline. For example:
>
> PS> .\python-script.py
>
> Opens a new window.
>
> PS> python python-script.py
>
> Does not. Is there a way to change this behaviour?
>
> Michael
Michael,

In your first example, "PS> .\python-script.py", PowerShell just
executes the file based on the association with the file's extension;
it basically passes the responsibility off to python.exe, which opens
a new console window and executes the file. It is just like opening a
text file ("PS> .\file.txt") or a Word document ("PS> .
\document.doc").

In the second example, you are specifying the name of an executable
that has a command-line interface, along with a command-line
parameter. Since that application can run in the PowerShell console,
it does.

I hope this clears things up a little.

Jeff
My System SpecsSystem Spec
Old 06-18-2008   #3 (permalink)
Roman Kuzmin


 
 

Re: New Window vs Inline

What is in your PATHEXT environment variable? I guess, extension ".py" is
not there. Try to add and see if it helps.

--
Thanks,
Roman Kuzmin

http://code.google.com/p/farnet/
PowerShell and .NET in FAR Manager


"Michael Elsdörfer" <michael@xxxxxx> wrote in message
news:OFD4KpP0IHA.3648@xxxxxx
Quote:

> I'm not quite unterstanding when Powershell decides to open a new command
> window vs. a command is run inline. For example:
>
> PS> .\python-script.py
>
> Opens a new window.
>
> PS> python python-script.py
>
> Does not. Is there a way to change this behaviour?
>
> Michael
My System SpecsSystem Spec
Old 06-18-2008   #4 (permalink)
Michael Elsdörfer


 
 

Re: New Window vs Inline

Roman Kuzmin schrieb:
Quote:

> What is in your PATHEXT environment variable? I guess, extension ".py"
> is not there. Try to add and see if it helps.
Didn't even know about PATHEXT - that does what I want. Thanks (Jeff too)!

Michael
My System SpecsSystem Spec
Old 06-18-2008   #5 (permalink)
Karl Prosser[MVP]


 
 

Re: New Window vs Inline

Thats a great observation Jeff.
Because. basically the fileassociation is doing the same as
[system.diagnostic.process]::start which will always open a new process
totally seperate from your console.. But when its the plain powershell
invocation, powershell knows that its a console application and runs it
through the same console.

The same test can be done in cmd.

in CMD.exe

type CMD.EXE

you get your new childshell inside the same console window

then try

START CMD.EXE

this spawns a totally new process, and its in a new window.


Jeff wrote:
Quote:

> On Jun 18, 11:17 am, Michael Elsdörfer <mich...@xxxxxx>
> wrote:
Quote:

>> I'm not quite unterstanding when Powershell decides to open a new
>> command window vs. a command is run inline. For example:
>>
>> PS> .\python-script.py
>>
>> Opens a new window.
>>
>> PS> python python-script.py
>>
>> Does not. Is there a way to change this behaviour?
>>
>> Michael
>
> Michael,
>
> In your first example, "PS> .\python-script.py", PowerShell just
> executes the file based on the association with the file's extension;
> it basically passes the responsibility off to python.exe, which opens
> a new console window and executes the file. It is just like opening a
> text file ("PS> .\file.txt") or a Word document ("PS> .
> \document.doc").
>
> In the second example, you are specifying the name of an executable
> that has a command-line interface, along with a command-line
> parameter. Since that application can run in the PowerShell console,
> it does.
>
> I hope this clears things up a little.
>
> Jeff
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Inline Photos in WLM Live Mail
Can't insert inline image Live Mail
Inline Photos Live Mail
Editing Inline HTML Vista mail
Viewing .jpg attachments inline Vista mail


Vista Forums 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 Ltd

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