tags:

views:

1194

answers:

6

I'm sure this must be possible, but I can't find out how to do it.

Any clues?

+2  A: 
$startinfo = new-object System.Diagnostics.ProcessStartInfo 
$startinfo.FileName = "explorer.exe"
$startinfo.WorkingDirectory = 'D:\foldername'

[System.Diagnostics.Process]::Start($startinfo)

Hope this helps
Alex
I don't know why this is getting voted down -- I can see not voting it up for the lack of elegance, but it's still a good (though wordy) answer :) You get my UP.
slipsec
I agree. It's a lot more code, but it allows some flexibility.
Mike Shepard
+3  A: 

Just use the invoke-item cmdlet. For example, if you want to open a explorer window on the current directory you can do:

invoke-item .
tomasr
+3  A: 
explorer .
danimajo
+6  A: 

You have a few options:

  • Powershell looks for executables in your path, just as cmd.exe does. So you can just type explorer on the powershell prompt. Using this method, you can also pass cmd-line arguments (see http://support.microsoft.com/kb/314853)
  • The Invoke-Item cmdlet provides a way to run an executable file or to open a file (or set of files) from within Windows PowerShell. Alias: ii
  • use system.diagnostics.process

Examples:

PS C:\> explorer
PS C:\> explorer .
PS C:\> explorer /n
PS C:\> Invoke-Item c:\windows\explorer.exe
PS C:\> ii c:\windows\explorer.exe
PS C:\> [diagnostics.process]::start("explorer.exe")

codeape
+14  A: 

ii .

Is one of the most common things I type at the PS command line.

EBGreen
It's funny that nobody answered this most simple answer but you. :)
halr9000
I'm a very simple person.
EBGreen
+1  A: 

Start explorer.exe

Simple single line command

powershelluser
"start ." works as well
spoon16