在 PowerShell 中如何進行確認後再停止程序?


若要在停止程序或例項之前獲取使用者同意,可以使用 -confirm 引數。

示例

在下例中,我們將使用 –Confirm 引數透過 –Id 4900 來停止 notepad.exe 程序。

PS C:\WINDOWS\system32> Stop-Process -Id 4900 -Confirm
Confirm
Are you sure you want to perform this action?
Performing the operation "Stop-Process" on target "notepad (4900)".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):

同樣,您可以使用 –Confirm 引數來透過名稱停止程序。

PS C:\WINDOWS\system32> Stop-Process -Name Notepad -Confirm

更新於:2020 年 1 月 22 日

274 次瀏覽

開啟您的 職業生涯

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.