2016年9月7日 星期三

tasklist process name

windows - How to check if a process is running via a batch script ...


>tasklist /FI "IMAGENAME eq notepad.exe"


步驟一:在「C:\Windows\system32\wbem」對 WMIC.EXE 按右鍵選「執行身份」,並切換到 Administrator 身份


C:\Users\user>for /f "tokens=2 delims=," %F in ('tasklist /nh /fi "imagename
 eq notepad.exe" /fo csv') do @echo %~F
7456

C:\Users\user>for /f "tokens=2 delims=," %F in ('tasklist /nh /fi "imagename
 eq chrome.exe" /fo csv') do @echo %~F
3252
7436

C:\Users\user>wmic process where caption="notepad.exe" get  ProcessId
ProcessId
7456


C:\Users\user>wmic process where caption="notepad.exe" get  ProcessId | MORE
 +1
7456

C:\Users\user>wmic /APPEND:C:\Temp\notepadpid.txt process where caption="not
epad.exe" get  ProcessId | MORE +1
7456
5856
452

---
Result

ProcessId  
7456       
ProcessId  
7456       
5856       

ProcessId  
7456       
5856       
452        
-------------

net stop Server
timeout /T 2
net start Server
set logfile=C:\waylog.log
echo starting way.bat at %date% %time% >> %logfile%


沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。