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

script with spaces in the path

Closed Thread
 
Thread Tools Display Modes
Old 11-15-2006   #1 (permalink)
Tim
Guest


 

script with spaces in the path

How would you execute a script file that has spaces in either it's parent
path or filename?
Old 11-15-2006   #2 (permalink)
Andrew Watt [MVP]
Guest


 

Re: script with spaces in the path

On Wed, 15 Nov 2006 11:42:01 -0800, Tim
<Tim@discussions.microsoft.com> wrote:

>How would you execute a script file that has spaces in either it's parent
>path or filename?


&"C:\Pro PowerShell\Chapter 18\Hello.ps1"
works for a script in my "Chapter 18" folder.

Andrew Watt MVP
Old 11-15-2006   #3 (permalink)
Tim
Guest


 

Re: script with spaces in the path

"Andrew Watt [MVP]" wrote:

> On Wed, 15 Nov 2006 11:42:01 -0800, Tim
> <Tim@discussions.microsoft.com> wrote:
>
> >How would you execute a script file that has spaces in either it's parent
> >path or filename?

>
> &"C:\Pro PowerShell\Chapter 18\Hello.ps1"
> works for a script in my "Chapter 18" folder.
>


How about from cmd or Run box? i.e.
powershell -command &"C:\Pro PowerShell\Chapter 18\Hello.ps1"
does not work.
Old 11-15-2006   #4 (permalink)
Andrew Watt [MVP]
Guest


 

Re: script with spaces in the path

On Wed, 15 Nov 2006 14:13:02 -0800, Tim
<Tim@discussions.microsoft.com> wrote:

>How about from cmd or Run box? i.e.
>powershell -command &"C:\Pro PowerShell\Chapter 18\Hello.ps1"
>does not work.


The following works from CMD.exe and from Run:

PowerShell -NoExit -command "&'C:\Pro PowerShell\Chapter
18\Hello.ps1'"

Andrew Watt MVP
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBS script with spaces in executable path Tyler Durden VB Script 6 6 Days Ago 02:30 PM
Re: running a program with spaces in Path with invoke-expression Kiron PowerShell 0 04-24-2008 10:41 AM
Re: running a program with spaces in Path with invoke-expression Spider Pig PowerShell 0 04-24-2008 08:02 AM
invoke-expression with .exe that has spaces in its path Michael Kelley PowerShell 1 03-30-2007 11:20 PM
can't run script from folder containing spaces delta99 PowerShell 3 03-07-2007 07:56 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