2
我在MS批處理(BAT)noobie。我需要通過VLC保存一些流媒體文件。 這個腳本爲我工作馬麗娟:如何批量獲取帶參數的cmd的pid?
@echo off
"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" "http://STREAM" --sout=#transcode{vcodec=h264,vb=1400,scale=1,acodec=mpga,ab=192,channels=2,deinterlace}:file{dst="D:\SOMEFILE.mp4"}
但我需要停止N秒後開始錄製。因此,我認爲最好的辦法是讓這種工藝在PID和運行
timeout /t 120 /nobreak taskkill /t /pid %PID%
爲此,我找到了一些解決方案:
@echo off
set "exe=C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"
set "source=http://STREAM"
set "save-cmd=--sout=#transcode{vcodec=h264,vb=1400,scale=1,acodec=mpga,ab=192,channels=2,deinterlace}:file{dst="D:\SOMEFILE.mp4"}"
for /f "tokens=2 delims==; " %%a in ('wmic process call create '"%exe%" "%source%" %save-cmd%' ^| find "ProcessId"') do set PID=%%a
echo "%PID%"
timeout /t 120 /nobreak
taskkill /t /pid %PID%
我得到PID,但VLC開通正常方式(什麼都不做),因爲我只是運行
我如何可以運行參數PROGRAMM並得到PID的呢? 謝謝!