本來一直在用tasklist來檢查一個進程是不是在運行的但是後來發現,如果是另外一個folder下面在運行,但是你要檢測的那個沒有運行呢?
只是單純的獲取進程在運行根本不管用,還必須要搞到進程的路徑,確定是自己這裏的在運行才行。
搜索了好久終於找到了個wmic命令,太強大了……
比如獲取指定進程的路徑命令:
C:/Documents and Settings/user>wmic process where name="qq.exe" get executablepath
ExecutablePath
F:/Program Files/Tencent/QQ2009/Bin/QQ.exe
以下爲從各個地方搜刮來的
更多的可以去看官方幫助文檔
另外推薦一個博客上面有很多信息
http://jiayu.blog.51cto.com/121732/22640
------------------------------------------------------------------------
process 進程管理工具
示例:
1.列舉當前的進程、進程路徑、命令行、進程ID、父進程ID、線程數,內存使用
::wmic process get
name,executablepath,commandline,processid,parentprocessid,threadcount,workingsetsize/value
2.列出進程notepad.exe的詳細信息
::wmic process where name="notepad.exe" get
/format:value
結果如下:
Caption=notepad.exe
CommandLine="C:/WINDOWS/system32/NOTEPAD.EXE"
F:/limin文檔/WMIC/新建
文本文檔.txt
CreationClassName=Win32_Process
CreationDate=20100429202435.656250+480
CSCreationClassName=Win32_ComputerSystem
CSName=20090621-1240
Description=notepad.exe
ExecutablePath=C:/WINDOWS/system32/NOTEPAD.EXE
ExecutionState=
Handle=3864
HandleCount=61
InstallDate=
KernelModeTime=12656250
MaximumWorkingSetSize=1413120
MinimumWorkingSetSize=204800
Name=notepad.exe
OSCreationClassName=Win32_OperatingSystem
OSName=Microsoft
Windows XP
Professional|C:/WINDOWS|
OtherOperationCount=9403
OtherTransferCount=226934
PageFaults=6341
PageFileUsage=2465792
ParentProcessId=1020
PeakPageFileUsage=2465792
PeakVirtualSize=43327488
PeakWorkingSetSize=6189056
Priority=8
PrivatePageCount=2465792
ProcessId=3864
QuotaNonPagedPoolUsage=5840
QuotaPagedPoolUsage=79436
QuotaPeakNonPagedPoolUsage=6784
QuotaPeakPagedPoolUsage=80428
ReadOperationCount=7
ReadTransferCount=31041
SessionId=0
Status=
TerminationDate=
ThreadCount=1
UserModeTime=3125000
VirtualSize=43327488
WindowsVersion=5.1.2600
WorkingSetSize=2990080
WriteOperationCount=3
WriteTransferCount=216
3.結束指定的進程
一示例:
結束進程CBTray.exe
::wmic process where name="CBTray.exe" call
terminate
示例二:
結束進程ID爲1020的進程
::wmic process where processid=1020 call
terminate
4.創建進程
創建notepad進程
::wmic process call create
"c:/windows/notepad.exe"
-------------------------------------------------------------------------------------
1. 查看進程詳細信息,這個命令會顯示進程的很多信息
wmic process where name="javaw.exe" get /format:value
2. 指定顯示某些列,可根據上面命令有選擇的顯示某些字段
wmic process where name="javaw.exe" get CommandLine,ProcessId
--------------------------------------------------------------------------------------------
Windows WMIC命令詳解
【例】將當前系統BIOS,CPU,主板等信息輸出到一個HTML網頁文件,命令如下:
::得到系統信息.bat,運行bat文件即可
::系統信息輸出到HTML文件,查看幫助: wmic /?
::wmic [系統參數名] list [brief|full] /format:hform >|>> [文件名]
wmic bios list brief /format:hform > PCinfo.html
wmic baseboard list brief /format:hform >>PCinfo.html
wmic cpu list full /format:hform >>PCinfo.html
wmic os list full /format:hform >>PCinfo.html
wmic computersystem list brief /format:hform >>PCinfo.html
wmic diskdrive list full /format:hform >>PCinfo.html
wmic memlogical list full /format:hform >>PCinfo.html
PCinfo.html
WMIC命令參數幫助參考:
ALIAS - 訪問本地機器上的別名