![](/img/trans.png)
[英]How can I change my system audio output / input device through Node JS (or command line)
[英]How can I parse the top line of output of a previous command as input to another command?
在bash中,我會為此使用awk和xargs,但是我不確定如何在Windows命令行上執行此操作。
基本上,我試圖殺死偵聽端口3000的進程。我目前正在這樣做:
netstat -ano | findstr:3000
taskkill /PID <process id found from previous command> /F
有沒有一種方法可以自動分析先前的命令以將它們鏈接在一行中,所以我不必一直手動輸入最新的PID? 或者,如果有人知道更好的方法,也將不勝感激。
您將需要使用for
循環來執行此操作,如下所示:
for /f "tokens=5" %A in ('netstat -ano ^| findstr /c:3000 ^| findstr /c:LISTENING') do taskkill /PID %A /F
希望這可以幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.