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 - File association bug?

Reply
 
Old 09-24-2007   #1 (permalink)
Suresh Govindachar


 
 

File association bug?

Hello,

After doing the following:

get-childitem -path envathext # for copy-paste in next command

set-item -path envathext -value
".pl;.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1"
Perl scripts such as execute: c:\no\space\path.pl
However, scripts with spaces in their path still need the prefix "perl"
need to add perl: perl "c:\path with\space.pl"
(No such problem in cmd.exe.)

--Suresh





My System SpecsSystem Spec
Old 09-24-2007   #2 (permalink)
Jon


 
 

Re: File association bug?


"Suresh Govindachar" <sgovindachar@xxxxxx> wrote in message
news:%23jLKNhs$HHA.4200@xxxxxx
Quote:

> Hello,
>
> After doing the following:
>
> get-childitem -path envathext # for copy-paste in next command
>
> set-item -path envathext -value
> ".pl;.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1"
> Perl scripts such as execute: c:\no\space\path.pl
> However, scripts with spaces in their path still need the prefix "perl"
> need to add perl: perl "c:\path with\space.pl"
> (No such problem in cmd.exe.)
>
> --Suresh
>

It's because what follows the space(s) are regarded as arguments to the
script / program, unless you use the quotes.


Some other alternatives

Invoke-Item "c:\path with\space.pl"
OR
& "c:\path with\space.pl"

Takes a bit of getting used to, though, I agree.


--
Jon


My System SpecsSystem Spec
Old 09-24-2007   #3 (permalink)
Suresh Govindachar


 
 

Re: File association bug?

Quote:

> It's because what follows the space(s) are regarded as arguments to the
> script / program, unless you use the quotes.
>
> Some other alternatives
>
> Invoke-Item "c:\path with\space.pl"
> OR
> & "c:\path with\space.pl"
Perhaps I was not clear:
Both cmd.exe and PS require quotes around filenames with spaces.
However,
In cmd.exe, one only needs the quotes;
in cmd.exe, one need _not_ add anything to the "file name".
in cmd.exe, just typing the "file name" causes it to be executed.
But in PS one must _prepend_ the "file name" with perl or & to execute
it.



My System SpecsSystem Spec
Old 09-24-2007   #4 (permalink)
Jon


 
 

Re: File association bug?


"Suresh Govindachar" <sgovindachar@xxxxxx> wrote in message
news:%23pKJZbv$HHA.1208@xxxxxx
Quote:

>
Quote:

>> It's because what follows the space(s) are regarded as arguments to the
>> script / program, unless you use the quotes.
>>
>> Some other alternatives
>>
>> Invoke-Item "c:\path with\space.pl"
>> OR
>> & "c:\path with\space.pl"
>
> Perhaps I was not clear:
> Both cmd.exe and PS require quotes around filenames with spaces.
> However,
> In cmd.exe, one only needs the quotes;
> in cmd.exe, one need _not_ add anything to the "file name".
> in cmd.exe, just typing the "file name" causes it to be executed.
> But in PS one must _prepend_ the "file name" with perl or & to execute
> it.
>
>
>

PowerShell works slightly differently.

If you type a set of characters in quotes then it's regarded as a string,
which is why you can type things like

$apples = 3
"There are $apples apples on the shelf"

OR

$a = "apple"; "apple".ToUpper()


etc

and those statements make sense. There are a lot of advantages to this in
other areas.

But returning to the point, when you type "c:\path with\space.pl" on its
own, it's regarded as a string.


--
Jon


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
lnk file association Vista file management
how to restore .zip file association & file icon in Vista? Vista file management
File association Vista file management
File Association Vista General
File association Vista file management


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