Launching Files with Spaces

What if you'd like to launch a file with spaces in its path? The first rule is that spaces are separators, so PowerShell would separate it at the spaces and break it up in several invalid paths, which is no good.

So whenever a path contains spaces, you need to quote it. Use single quotes unless you want to resolve variables that are part of your path name. Then, you should use double quotes.

This leads to another problem. Once quoted, PowerShell treats your command as a plain string and echoes it back to you. To invoke the string, add "&" or "." like this:

& "$env:programfiles\Internet Explorer\iexplore.exe"

Posted May 27 2009, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.