2012-08-23 47 views
2

我從Powershell啓動了「Explorer.exe」,並希望獲取資源管理器窗口的進程ID,以便我不會在其他資源管理器窗口上誤操作。如何獲取從Powershell啓動的資源管理器的進程ID

代碼:Start-Process「Explorer.exe」-PassThru 結果:我可以看到進程ID,但它與UISpy或任務管理器中窗口的實際進程ID不同。似乎explorer.exe啓動另一個進程(B)可以退出自己,最後我們看到進程(B)。我得到的過程是退出的過程。 問題:如何獲得真實的進程ID(B)?

回答

4

Explorer.exe將暫時啓動一個全新的進程,但該進程會很快死亡,將其狀態切換到現有的資源管理器進程。一般來說,它不會像大多數程序那樣堅持並增加不斷增加的過程。

在操作中查看:

"Old explorer.exe instances" 
Get-Process explorer 

Start-Process explorer.exe 
sleep 1 # wait for this one to die 

"New explorer.exe instances" 
Get-Process explorer 

你會看到它的同一套資源管理器的實例。我認爲這與註冊碼有關HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced [SeparateProcess]

+0

非常感謝。這有幫助。 – asuradancing

相關問題