Explorer in Explorer Mode

Link. October 11, 2008. Comments [5]. Posted in: PowerShell

I tend to fire up Windows Explorer instances from my prompt very often, either on the current directory or in other spots. I was pretty used to using the “explorer /e,<path>” command from CMD.EXE but I never had figured out exactly how to use it on PowerShell and have it work reliably: Paths with spaces always caused it to open the default documents folder instead.

Finally sat down and played with it until I got it right:

# open explorer in this directory
function exp([string] $loc = '.') {
   explorer "/e,"$loc""
}


Sunday, October 12, 2008 10:35:01 AM (SA Pacific Standard Time, UTC-05:00)
Try 'invoke-item -path .' or 'ii .'

James
Sunday, October 12, 2008 5:24:07 PM (SA Pacific Standard Time, UTC-05:00)
If James hadn't said that I was going to. :)
Monday, October 13, 2008 8:29:10 AM (SA Pacific Standard Time, UTC-05:00)
Thanks guys! Yes, it occurred to me later on that I could just "execute" the path and get the right behavior, but, to be honest, getting the right explorer parameters was a challenge I wanted to get done :) (I'm still not 100% sure why the above works while "/e,`"$loc`"" didn't).
Monday, October 13, 2008 12:21:04 PM (SA Pacific Standard Time, UTC-05:00)
Never have used that command, thanks for sharing (I always used "start ."). Strangely enough, both these commands worked without errors:

$loc = "."
explorer "/e,"$loc""
explorer "/e,`"$loc`""
Jason Archer
Monday, October 13, 2008 1:00:10 PM (SA Pacific Standard Time, UTC-05:00)
Jason: Yes, that works for me if $loc doesn't have spaces in it. That's when it breaks for me.
Comments are closed.

Syndicate

About

Tomas Restrepo is a software developer located in Colombia, South America. His interests include .NET, Connected Systems, PowerShell and lately dynamic programming languages. More...

tomasrestrepo @ twitter My Flickr photostream My saved links on delicious My Technorati Profile

email: tomas@winterdom.com
msn: tomasr@passport.com

View my profile on LinkedIn

MVP logo

Ads


Categories

Statistics

Total Posts: 1051
This Year: 2
This Month: 2
This Week: 1
Comments: 827

Archive

Other

Copyright © 2002-2008, Tomas Restrepo.

Powered by: newtelligence dasBlog 2.2.8279.16125

Sign In