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 - How to execute (perl) scripts in Powershell without DOS box

Reply
 
Old 11-22-2006   #1 (permalink)
Thomas Mogwitz


 
 

How to execute (perl) scripts in Powershell without DOS box

Hi folks,

I am trying to execute a bunch of perl scripts from within a Powershell
by simply writing their name (and pressing Return, of course). The
problem is, everytime I do so a DOS box (cmd.exe) pops up, displays
the script output and closes itself. I instead want to see the output
in my Powershell.
I get the desired result by executing "perl.exe xyz.pl", but why not
when I simply execute the script?

I searched the registry and found out that the file ending '.pl' is
associated with a 'PersistentHandler' that is connected to a class id with
'query.dll' as 'InProcServer32'. Here I'm stuck. I suppose that this
query.dll again searches the registry for the registered file type .pl and
finds out that it is linked to the file type 'Perl', which has a shell open
command 'perl.exe %1'. So what's the difference between finding that
out and running perl.exe with my script and me executing
"perl.exe xyz.pl"?

My System SpecsSystem Spec
Old 11-23-2006   #2 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: How to execute (perl) scripts in Powershell without DOS box

What Perl distribution are you using?

For me with ActiveState Perl this "just works". It sounds like there is some
kind of proxying handler that was installed with Perl or as an addon that is
getting in the way.

"Thomas Mogwitz" <Thomas Mogwitz@discussions.microsoft.com> wrote in message
news:2E198CE6-2D74-440E-AC0B-E8E5E55CF5D5@microsoft.com...
> Hi folks,
>
> I am trying to execute a bunch of perl scripts from within a Powershell
> by simply writing their name (and pressing Return, of course). The
> problem is, everytime I do so a DOS box (cmd.exe) pops up, displays
> the script output and closes itself. I instead want to see the output
> in my Powershell.
> I get the desired result by executing "perl.exe xyz.pl", but why not
> when I simply execute the script?
>
> I searched the registry and found out that the file ending '.pl' is
> associated with a 'PersistentHandler' that is connected to a class id with
> 'query.dll' as 'InProcServer32'. Here I'm stuck. I suppose that this
> query.dll again searches the registry for the registered file type .pl and
> finds out that it is linked to the file type 'Perl', which has a shell
> open
> command 'perl.exe %1'. So what's the difference between finding that
> out and running perl.exe with my script and me executing
> "perl.exe xyz.pl"?



My System SpecsSystem Spec
Old 11-23-2006   #3 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: How to execute (perl) scripts in Powershell without DOS box

Check the value of this variable from within PowerShell:
$envathext
I can replicate the behavior you see if I remove .pl from the executable
extensions there. If it doesn't contain .pl, add it - e.g.,
$envathext = "${envathext};.pl"

"Thomas Mogwitz" <Thomas Mogwitz@discussions.microsoft.com> wrote in message
news:2E198CE6-2D74-440E-AC0B-E8E5E55CF5D5@microsoft.com...
> Hi folks,
>
> I am trying to execute a bunch of perl scripts from within a Powershell
> by simply writing their name (and pressing Return, of course). The
> problem is, everytime I do so a DOS box (cmd.exe) pops up, displays
> the script output and closes itself. I instead want to see the output
> in my Powershell.
> I get the desired result by executing "perl.exe xyz.pl", but why not
> when I simply execute the script?
>
> I searched the registry and found out that the file ending '.pl' is
> associated with a 'PersistentHandler' that is connected to a class id with
> 'query.dll' as 'InProcServer32'. Here I'm stuck. I suppose that this
> query.dll again searches the registry for the registered file type .pl and
> finds out that it is linked to the file type 'Perl', which has a shell
> open
> command 'perl.exe %1'. So what's the difference between finding that
> out and running perl.exe with my script and me executing
> "perl.exe xyz.pl"?



My System SpecsSystem Spec
Old 11-23-2006   #4 (permalink)
Thomas Mogwitz


 
 

Re: How to execute (perl) scripts in Powershell without DOS box

I'm using ActiveState Perl 5.8.8 (Build 816). I installed Perl before I
installed Microsoft Powershell. So my question remains...

Can you elaborate (by example of your machine), what actions
Windows does when you execute a perl script from within Powershell,
so I can understand the mechanisms in full and can check out which
differences on my machine prevent it from working?

"Alex K. Angelopoulos [MVP]" wrote:

> What Perl distribution are you using?
>
> For me with ActiveState Perl this "just works". It sounds like there is some
> kind of proxying handler that was installed with Perl or as an addon that is
> getting in the way.
>
> "Thomas Mogwitz" <Thomas Mogwitz@discussions.microsoft.com> wrote in message
> news:2E198CE6-2D74-440E-AC0B-E8E5E55CF5D5@microsoft.com...
> > Hi folks,
> >
> > I am trying to execute a bunch of perl scripts from within a Powershell
> > by simply writing their name (and pressing Return, of course). The
> > problem is, everytime I do so a DOS box (cmd.exe) pops up, displays
> > the script output and closes itself. I instead want to see the output
> > in my Powershell.
> > I get the desired result by executing "perl.exe xyz.pl", but why not
> > when I simply execute the script?
> >
> > I searched the registry and found out that the file ending '.pl' is
> > associated with a 'PersistentHandler' that is connected to a class id with
> > 'query.dll' as 'InProcServer32'. Here I'm stuck. I suppose that this
> > query.dll again searches the registry for the registered file type .pl and
> > finds out that it is linked to the file type 'Perl', which has a shell
> > open
> > command 'perl.exe %1'. So what's the difference between finding that
> > out and running perl.exe with my script and me executing
> > "perl.exe xyz.pl"?

>
>
>

My System SpecsSystem Spec
Old 11-25-2006   #5 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: How to execute (perl) scripts in Powershell without DOS box

See my second response. I suspect the problem is that .pl files aren't
listed in your $envathext variable.

"Thomas Mogwitz" <ThomasMogwitz@discussions.microsoft.com> wrote in message
news:B37A6298-9C50-4A49-8489-DEC11D6684A1@microsoft.com...
> I'm using ActiveState Perl 5.8.8 (Build 816). I installed Perl before I
> installed Microsoft Powershell. So my question remains...
>
> Can you elaborate (by example of your machine), what actions
> Windows does when you execute a perl script from within Powershell,
> so I can understand the mechanisms in full and can check out which
> differences on my machine prevent it from working?
>
> "Alex K. Angelopoulos [MVP]" wrote:
>
>> What Perl distribution are you using?
>>
>> For me with ActiveState Perl this "just works". It sounds like there is
>> some
>> kind of proxying handler that was installed with Perl or as an addon that
>> is
>> getting in the way.
>>
>> "Thomas Mogwitz" <Thomas Mogwitz@discussions.microsoft.com> wrote in
>> message
>> news:2E198CE6-2D74-440E-AC0B-E8E5E55CF5D5@microsoft.com...
>> > Hi folks,
>> >
>> > I am trying to execute a bunch of perl scripts from within a Powershell
>> > by simply writing their name (and pressing Return, of course). The
>> > problem is, everytime I do so a DOS box (cmd.exe) pops up, displays
>> > the script output and closes itself. I instead want to see the output
>> > in my Powershell.
>> > I get the desired result by executing "perl.exe xyz.pl", but why not
>> > when I simply execute the script?
>> >
>> > I searched the registry and found out that the file ending '.pl' is
>> > associated with a 'PersistentHandler' that is connected to a class id
>> > with
>> > 'query.dll' as 'InProcServer32'. Here I'm stuck. I suppose that this
>> > query.dll again searches the registry for the registered file type .pl
>> > and
>> > finds out that it is linked to the file type 'Perl', which has a shell
>> > open
>> > command 'perl.exe %1'. So what's the difference between finding that
>> > out and running perl.exe with my script and me executing
>> > "perl.exe xyz.pl"?

>>
>>
>>



My System SpecsSystem Spec
Old 11-27-2006   #6 (permalink)
Thomas Mogwitz


 
 

Re: How to execute (perl) scripts in Powershell without DOS box

Yes, that's the solution. .pl wasn't in my pathext variable, and by adding it
I achieved the behaviour I wanted.
Thank you very much for your help!

"Alex K. Angelopoulos [MVP]" wrote:

> Check the value of this variable from within PowerShell:
> $envathext
> I can replicate the behavior you see if I remove .pl from the executable
> extensions there. If it doesn't contain .pl, add it - e.g.,
> $envathext = "${envathext};.pl"
>
> "Thomas Mogwitz" <Thomas Mogwitz@discussions.microsoft.com> wrote in message
> news:2E198CE6-2D74-440E-AC0B-E8E5E55CF5D5@microsoft.com...
> > Hi folks,
> >
> > I am trying to execute a bunch of perl scripts from within a Powershell
> > by simply writing their name (and pressing Return, of course). The
> > problem is, everytime I do so a DOS box (cmd.exe) pops up, displays
> > the script output and closes itself. I instead want to see the output
> > in my Powershell.
> > I get the desired result by executing "perl.exe xyz.pl", but why not
> > when I simply execute the script?
> >
> > I searched the registry and found out that the file ending '.pl' is
> > associated with a 'PersistentHandler' that is connected to a class id with
> > 'query.dll' as 'InProcServer32'. Here I'm stuck. I suppose that this
> > query.dll again searches the registry for the registered file type .pl and
> > finds out that it is linked to the file type 'Perl', which has a shell
> > open
> > command 'perl.exe %1'. So what's the difference between finding that
> > out and running perl.exe with my script and me executing
> > "perl.exe xyz.pl"?

>
>
>

My System SpecsSystem Spec
Old 11-27-2006   #7 (permalink)
Bruce Payette [MSFT]


 
 

Re: How to execute (perl) scripts in Powershell without DOS box

Yes -we check $ENV:PATHEXT before directly executing a file. If the
extension is not there, then ShellExecute will be used instead which is why
you're seeing the pop-ups.

-bruce

--
Bruce Payette [MSFT]
Windows PowerShell Technical Lead
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.



"Thomas Mogwitz" <ThomasMogwitz@discussions.microsoft.com> wrote in message
news:4F8CBEFD-B7D4-40A2-BB79-E05D11FE583D@microsoft.com...
> Yes, that's the solution. .pl wasn't in my pathext variable, and by adding
> it
> I achieved the behaviour I wanted.
> Thank you very much for your help!
>
> "Alex K. Angelopoulos [MVP]" wrote:
>
>> Check the value of this variable from within PowerShell:
>> $envathext
>> I can replicate the behavior you see if I remove .pl from the executable
>> extensions there. If it doesn't contain .pl, add it - e.g.,
>> $envathext = "${envathext};.pl"
>>
>> "Thomas Mogwitz" <Thomas Mogwitz@discussions.microsoft.com> wrote in
>> message
>> news:2E198CE6-2D74-440E-AC0B-E8E5E55CF5D5@microsoft.com...
>> > Hi folks,
>> >
>> > I am trying to execute a bunch of perl scripts from within a Powershell
>> > by simply writing their name (and pressing Return, of course). The
>> > problem is, everytime I do so a DOS box (cmd.exe) pops up, displays
>> > the script output and closes itself. I instead want to see the output
>> > in my Powershell.
>> > I get the desired result by executing "perl.exe xyz.pl", but why not
>> > when I simply execute the script?
>> >
>> > I searched the registry and found out that the file ending '.pl' is
>> > associated with a 'PersistentHandler' that is connected to a class id
>> > with
>> > 'query.dll' as 'InProcServer32'. Here I'm stuck. I suppose that this
>> > query.dll again searches the registry for the registered file type .pl
>> > and
>> > finds out that it is linked to the file type 'Perl', which has a shell
>> > open
>> > command 'perl.exe %1'. So what's the difference between finding that
>> > out and running perl.exe with my script and me executing
>> > "perl.exe xyz.pl"?

>>
>>
>>



My System SpecsSystem Spec
Old 11-29-2006   #8 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: How to execute (perl) scripts in Powershell without DOS box

btw, I'm beginning to think that PowerShell should be able to make decisions
about "document execution" that are distinct from the Windows shell
decisions. Has a PS-based ftype/assoc "overlay" ability been discussed yet?
I think we can make a good case for this.

"Bruce Payette [MSFT]" <brucepay@microsoft.com> wrote in message
news:erKkIonEHHA.1220@TK2MSFTNGP04.phx.gbl...
> Yes -we check $ENV:PATHEXT before directly executing a file. If the
> extension is not there, then ShellExecute will be used instead which is
> why you're seeing the pop-ups.
>
> -bruce
>
> --
> Bruce Payette [MSFT]
> Windows PowerShell Technical Lead
> Microsoft Corporation
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
>
> "Thomas Mogwitz" <ThomasMogwitz@discussions.microsoft.com> wrote in
> message news:4F8CBEFD-B7D4-40A2-BB79-E05D11FE583D@microsoft.com...
>> Yes, that's the solution. .pl wasn't in my pathext variable, and by
>> adding it
>> I achieved the behaviour I wanted.
>> Thank you very much for your help!
>>
>> "Alex K. Angelopoulos [MVP]" wrote:
>>
>>> Check the value of this variable from within PowerShell:
>>> $envathext
>>> I can replicate the behavior you see if I remove .pl from the executable
>>> extensions there. If it doesn't contain .pl, add it - e.g.,
>>> $envathext = "${envathext};.pl"
>>>
>>> "Thomas Mogwitz" <Thomas Mogwitz@discussions.microsoft.com> wrote in
>>> message
>>> news:2E198CE6-2D74-440E-AC0B-E8E5E55CF5D5@microsoft.com...
>>> > Hi folks,
>>> >
>>> > I am trying to execute a bunch of perl scripts from within a
>>> > Powershell
>>> > by simply writing their name (and pressing Return, of course). The
>>> > problem is, everytime I do so a DOS box (cmd.exe) pops up, displays
>>> > the script output and closes itself. I instead want to see the output
>>> > in my Powershell.
>>> > I get the desired result by executing "perl.exe xyz.pl", but why not
>>> > when I simply execute the script?
>>> >
>>> > I searched the registry and found out that the file ending '.pl' is
>>> > associated with a 'PersistentHandler' that is connected to a class id
>>> > with
>>> > 'query.dll' as 'InProcServer32'. Here I'm stuck. I suppose that this
>>> > query.dll again searches the registry for the registered file type .pl
>>> > and
>>> > finds out that it is linked to the file type 'Perl', which has a shell
>>> > open
>>> > command 'perl.exe %1'. So what's the difference between finding that
>>> > out and running perl.exe with my script and me executing
>>> > "perl.exe xyz.pl"?
>>>
>>>
>>>

>
>



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
In Powershell execute scripts on many remote machines ,Monitor and report back General Discussion
PowerShell and Perl interoperability PowerShell
Execute PowerShell Scripts via http url requests PowerShell
Right-click execute scripts ? PowerShell
AD LogOn Scripts Execute permissions Vista account administration


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