Is it possible to open a Windows Explorer window from PowerShell?

后端 未结 10 535
小鲜肉
小鲜肉 2020-12-07 07:21

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

Any clues?

10条回答
  •  情深已故
    2020-12-07 07:38

    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:\path\
    PS C:\> ii c:\path\
    PS C:\> Invoke-Item c:\windows\explorer.exe
    PS C:\> ii c:\windows\explorer.exe
    PS C:\> [diagnostics.process]::start("explorer.exe")
    

提交回复
热议问题