前沿:WMIC命令在咱們的工做中能夠幫助咱們減小對其餘工具的依賴並節省咱們的時間,實在是一個值得學習和研究的好東西node
命令不少,這裏我把網上目前能找到的較實用的一些命令整理出來,但願各位看官能找到本身須要的東西
詳細的命令使用方法你們能夠參考微軟幫助
http://technet.microsoft.com/zh-cn/library/cc779482(WS.10).
aspx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
得到系統版本信息
wmic datafile where Name='c:\\windows\\explorer.exe' get Manufacturer,Version,Filename
得到系統進程
wmic process list full 注意:
這裏的full也能夠換成brief(簡潔)
得到硬件信息(這裏以cpu爲例)
wmic cpu get name,caption,maxclockspeed,description
將結果輸出到d盤的1.txt裏面
wmic /output:D:\1.txt cpu get name
wmic 獲取硬盤固定分區盤符:
wmic logicaldisk where "drivetype=3" get name
wmic 獲取硬盤各分區文件系統以及可用空間:
wmic logicaldisk where "drivetype=3" get name,filesystem,freespace
wmic 獲取進程名稱以及可執行路徑:
wmic process get name,executablepath
wmic 刪除指定進程(根據進程名稱):
wmic process where name="qq.exe" call terminate
或者用
wmic process where name="qq.exe" delete
wmic 刪除指定進程(根據進程PID):
wmic process where pid="123" delete
wmic 建立新進程
wmic process call create "C:\Program Files\Tencent\QQ\QQ.exe"
在遠程機器上建立新進程:
wmic /node:192.168.1.10 /user:administrator /password:123456 process call create cmd.exe
關閉本地計算機
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 結束可疑進程(根據進程的啓動路徑)
wmic process where "name='explorer.exe' and executablepath<>'%SystemDrive%\\windows\\explorer.exe'" delete
wmic 獲取物理內存
wmic memlogical get TotalPhysicalMemory|find /i /v "t"
wmic 獲取文件的建立、訪問、修改時間
@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
獲取共享資源(包括隱藏共享)
WMIC share list brief
獲取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)
得到進程當前佔用的內存和最大佔用內存的大小:
wmic process where caption='filename.exe' get WorkingSetSize,PeakWorkingSetSize
更改現有工做組爲指定的工做組
wmic computersystem Where "name='計算機名稱' call UnjoinDomainOrWorkgroup
退出所在域
wmic computersystem Where "name='計算機名稱'" call joindomainorworkgroup "",1,"域名稱","域管理員密碼","域管理員用戶名"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
開2003的3389
wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call
SetAllowTSConnections 1
遠程打開計算機遠程桌面
wmic /node:%pcname% /USER:%pcaccount% PATH win32_terminalservicesetting WHERE (__Class!="") CALL SetAllowTSConnections 1
添加的計劃任務,wmic添加的一樣AT命令也是能夠看到
wmic job call create "sol.exe",0,0,true,false,********154800.000000+480
wmic job call create "sol.exe",0,0,1,0,********154600.000000+480
這兩句是相同的,TRUE能夠用1表示,一樣的FALSE能夠用0值表示,時間前爲什麼用八個星號,這是WMIC的特性,他顯示時間的方式是YYYYMMDDHHMMSS.MMMMMM+時區 ,但是,咱們並不須要指定年份和月份還有天,因此用*星號來替代
wmic bios list full
wmic還有中止、暫停和運行服務的功能:
啓動服務startservice,中止服務stopservice,暫停服務pauseservice。
具體的命令使用格式就是:
wmic Service where caption=」
windows time」 call stopservice
●--中止服務
wmic Service where caption=」windows time」 call startservice
●--啓動服務
wmic Service where name=」w32time」 call stopservice
●--中止服務,注意name和caption的區別。
遠程建立進程
wmic /node:109.254.2.102 /user:"rdgad\administrator" /password:"1234" process call create commandline="cmd.exe /k echo xxxxx|clip.exe"