wmic用法示例關(guān)鍵字: wmic wmiwmic 獲取硬盤固定分區(qū)盤符:
wmic logicaldisk where "drivetype=3" get name wmic 獲取硬盤各分區(qū)文件系統(tǒng)以及可用空間: wmic logicaldisk where "drivetype=3" get name,filesystem,freespace wmic 獲取進程名稱以及可執(zhí)行路徑: wmic process get name,executablepath wmic 刪除指定進程(根據(jù)進程名稱): wmic process where name="qq.exe" call terminate 或者用 wmic process where name="qq.exe" delete wmic 刪除指定進程(根據(jù)進程PID): wmic process where pid="123" delete wmic 創(chuàng)建新進程 wmic process call create "C:\Program Files\Tencent\QQ\QQ.exe" 在遠程機器上創(chuàng)建新進程: wmic /node:192.168.1.10 /user:administrator /password:123456 process call create cmd.exe 關(guān)閉本地計算機 wmic process call create shutdown.exe 重啟遠程計算機 wmic /node:192.168.1.10/user:administrator /password:123456 process call create "shutdown.exe -r -f -m" 更改計算機名稱 wmic computersystem where "caption='%ComputerName%'" call rename newcomputername 更改帳戶名 wmic USERACCOUNT where "name='%UserName%'" call rename newUserName wmic 結(jié)束可疑進程(根據(jù)進程的啟動路徑) wmic process where "name='explorer.exe' and executablepath<>'%SystemDrive%\\windows\\explorer.exe'" delete wmic 獲取物理內(nèi)存 wmic memlogical get TotalPhysicalMemory|find /i /v "t" wmic 獲取文件的創(chuàng)建、訪問、修改時間 @echo off 'wmic datafile where name^="c:\\windows\\system32\\notepad.exe" get CreationDate^,LastAccessed^,LastModified wmic 全盤搜索某文件并獲取該文件所在目錄 wmic datafile where "FileName='qq' and extension='exe'" get drive,path for /f "skip=1 tokens=1*" %i in ('wmic datafile where "FileName='qq' and extension='exe'" get drive^,path') do (set "qPath=%i%j"&@echo %qPath:~0,-3%) 獲取屏幕分辨率 wmic DESKTOPMONITOR where Status='ok' get ScreenHeight,ScreenWidth 獲取U盤盤符,并運行U盤上的QQ.exe @for /f "skip=1 tokens=*" %i in ('wmic logicaldisk where "drivetype=2" get name') do (if not "%i"=="" start d:\qq.exe) 獲得進程當前占用的內(nèi)存和最大占用內(nèi)存的大?。? wmic process where caption='filename.exe' get WorkingSetSize,PeakWorkingSetSize 把內(nèi)存大小改成KB(MB的話可能有小數(shù)) @echo off for /f "skip=1 tokens=1-2 delims= " %%a in ('wmic process where caption^="conime.exe" get WorkingSetSize^,PeakWorkingSetSize') do ( set /a m=%%a/1024 set /a mm=%%b/1024 echo 進程conime.exe現(xiàn)在占用內(nèi)存:%m%K;最高占用內(nèi)存:%mm%K ) pause |
|