how to open a folder within Powershell
PowershellPowershell Problem Overview
How to open a folder in PowerShell? I am not talking on how to start PowerShell in a specific folder.
What I mean is that in the command line of powershell i would like to open a folder e.g: " open document"
Powershell Solutions
Solution 1 - Powershell
Use the Invoke-Item
cmdlet, or its alias: ii.
PS> ii c:\windows # open the windows directory in windows explorer
PS> ii c:\book.xls # open book.xls in Excel
PS> ii . # open the current directory in windows explorer
Solution 2 - Powershell
For Powershell and cmd compatible way ( and I think the most common way):
start .
start c:\
Solution 3 - Powershell
To open the current folder within the powershell type:
PS>> explorer.exe $(pwd)
Solution 4 - Powershell
Use Invoke-Item
, alias ii
:
ii d:\temp\
Solution 5 - Powershell
you can use the explorer.exe to open the folder:
explorer.exe c:\temp\
explorer.exe <YourFolderPathHere>
Solution 6 - Powershell
Just to add as well to the mix:
PS C:\> ii -path c:\directory\directory\directory
If your file name has two words with a separation consider single quotation marks:
PS C:\> ii -path 'c:\directory\directory\directory directory\'
The following work [note -path is optional]
1. ii or invoke-item
2. explorer.exe
3. start
Solution 7 - Powershell
I realize the question is old but folks finding this via google may find this useful even now:
I created a cmd script with:
@REM Open directory
@REM Version 1.0
@echo off
if [%1]==[] (powershell ii .
) Else (
powershell ii %1
cd %1
)
This will also open a document such as a text file or a MS Word document, as well as opening a folder.
Solution 8 - Powershell
I don't exactly understand what you want, but I have two possible solutions:
explorer .\Documents
or
cd .\Documents
Solution 9 - Powershell
Putting a dot after explorer.exe
will open the current directory:
explorer.exe .
Solution 10 - Powershell
As 'open .' in mac will open the current directory, 'start .' in window PowerShell will do the same.
Solution 11 - Powershell
another variant
hh c:\
hh http://stackoverflow.com/questions/8471106
hh $env:windir\help\WindowsPowerShellHelp.chm