2010-08-03 100 views

回答

20

在Windows中,你可以用下面的命令來打開資源管理器:

C:\Users\Leniel>start %windir%\explorer.exe 

如果你想讓它打開特定文件夾,例如這樣做:

C:\Users\Leniel>start %windir%\explorer.exe "C:\Users\Leniel\Desktop" 
+0

whooooo正是我需要的。也在我的鼻子下面。 :) – 2010-08-03 21:45:43

+5

您通常可以完全忽略資源管理器:'start「c:\ mydir」' – 2010-08-03 21:47:14

+0

另外啓動GUI程序'start'完全不需要。此外,'explorer'位於'%PATH%'中,因此無論如何'explorer someDir'就足夠了。 – Joey 2010-08-09 10:22:25

13

的OS X的直接等同openstartcmd

start foo.txt 

將啓動記事本(或任何文本編輯器,你正在使用),

start http://example.com 

將推出瀏覽器,

start \someDirectory 

將推出瀏覽器等

必須注意引號中的參數,因爲start將解釋第一個引號d參數作爲窗口標題使用,所以像

start "C:\Users\Me\Folder with spaces\somedocument.docx" 

將無法​​正常工作。相反,在這種情況下,在前面加上一個空的報價參數:

start "" "C:\Users\Me\Folder with spaces\somedocument.docx" 

注意start不是一個單獨的程序,但殼內置。所以,從外部程序調用這個你必須使用像

cmd /c start ... 

在PowerShell中的等價物或者是Start-ProcessInvoke-Item。後者可能更適合這項任務。

Invoke-Item foo.txt # launches your text editor with foo.txt 
Invoke-Item .  # starts Explorer in the current directory 

至於Windows的API,你正在尋找ShellExecuteopen動詞。

相關問題