1.wmic=Microsoft Windows Management Instrumentation
2. C:\WINDOWS\system32\wbem 下的東西,特別是.xsl格式化文件,實現wmic的格式化輸出
如wmic /output:c:\process.html process list /format:htable.xsl
/format:textvaluelist.xsl
/format:hform.xsl
/format:htable.xslhtml
/format:csv.xslios
/format:xml.xsl網絡
3.wmic能夠作什麼?系統管理、遠程主機信息獲取。。。均可以dom
4.wmic /?google
查看wmic對象有何可用屬性: wmic 對象名稱 get /? 例如
wmic process get /?spa
查看wmic對象某個屬性的值: wmic 對象名稱 get 對象某個屬性 例如
wmic process get name操作系統
PROCESS - 進程管理orm
::列出進程的核心信息,相似任務管理器
wmic process list briefxml
::新建notepad進程
wmic process call create notepadhtm
::列出進程的信息
wmic process get caption,handle,commandline,executablepath
::結束進程
wmic process [handle/PID] delete
wmic process [handle/PID] call terminate
::結束svchost.exe進程,路徑爲非C:\WINDOWS\system32\svchost.exe的
wmic process where "name='svchost.exe' and ExecutablePath<>'C:\\WINDOWS\\system32\\svchost.exe'" call Terminate
::結束svchost.exe進程,路徑爲C:\WINDOWS\svchost.exe的(關鍵點:路徑中的\必定要換成\\)
wmic process where "name='svchost.exe' and ExecutablePath='C:\\WINDOWS\\svchost.exe'" call Terminate
BIOS - 基本輸入/輸出服務 (BIOS) 管理
::查看bios版本型號
wmic bios get name,SMBIOSBIOSVersion,manufacturer
COMPUTERSYSTEM - 計算機系統管理
::查看硬件、操做系統基本信息
wmic computersystem get Name,workgroup,NumberOfProcessors,manufacturer,Model
::查看系統啓動選項boot.ini的內容
wmic computersystem get SystemStartupOptions
::查看工做組/域
wmic computersystem get domain
::更改計算機名abc爲123
wmic computersystem where "name='abc'" call rename 123
::更改工做組google爲MyGroup
wmic computersystem where "name='google'" call joindomainorworkgroup "","","MyGroup",1
CPU - CPU 管理
::查看cpu型號
wmic cpu get name
DATAFILE - DataFile 管理
::查找e盤下test目錄(不包括子目錄)下的cc.cmd文件
wmic datafile where "drive='e:' and path='\\test\\' and FileName='cc' and Extension='cmd'" list
::查找e盤下全部目錄和子目錄下的cc.cmd文件,且文件大小大於1K
wmic datafile where "drive='e:' and FileName='cc' and Extension='cmd' and FileSize>'1000'" list
::刪除e盤下文件大小大於10M的.cmd文件
wmic datafile where "drive='e:' and Extension='cmd' and FileSize>'10000000'" call delete
::刪除e盤下test目錄(不包括子目錄)下的非.cmd文件
wmic datafile where "drive='e:' and Extension<>'cmd' and path='test'" call delete
::複製e盤下test目錄(不包括子目錄)下的cc.cmd文件到e:\,並更名爲aa.bat
wmic datafile where "drive='e:' and path='\\test\\' and FileName='cc' and Extension='cmd'" call copy "e:\aa.bat"
::更名c:\hello.txt爲c:\test.txt
wmic datafile "c:\\hello.txt" call rename c:\test.txt
::查找h盤下目錄含有test,文件名含有perl,後綴爲txt的文件
wmic datafile where "drive='h:' and extension='txt' and path like '%\\test\\%' and filename like '%perl%'" get name
DESKTOPMONITOR - 監視器管理
::獲取屏幕分辨率
wmic DESKTOPMONITOR where Status='ok' get ScreenHeight,ScreenWidth
DISKDRIVE - 物理磁盤驅動器管理
::獲取物理磁盤型號大小等
wmic DISKDRIVE get Caption,size,InterfaceType
ENVIRONMENT - 系統環境設置管理
::獲取temp環境變量
wmic ENVIRONMENT where "name='temp'" get UserName,VariableValue
::更改path環境變量值,新增e:\tools
wmic ENVIRONMENT where "name='path' and username='<system>'" set VariableValue="%path%;e:\tools"
::新增系統環境變量home,值爲%HOMEDRIVE%%HOMEPATH%
wmic ENVIRONMENT create name="home",username="<system>",VariableValue="%HOMEDRIVE%%HOMEPATH%"
::刪除home環境變量
wmic ENVIRONMENT where "name='home'" delete
FSDIR - 文件目錄系統項目管理
::查找e盤下名爲test的目錄
wmic FSDIR where "drive='e:' and filename='test'" list
::刪除e:\test目錄下除過目錄abc的全部目錄
wmic FSDIR where "drive='e:' and path='\\test\\' and filename<>'abc'" call delete
::刪除c:\good文件夾
wmic fsdir "c:\\good" call delete
::重命名c:\good文件夾爲abb
wmic fsdir "c:\\good" rename "c:\abb"
LOGICALDISK - 本地儲存設備管理
::獲取硬盤系統格式、總大小、可用空間等
wmic LOGICALDISK get name,Description,filesystem,size,freespace
NIC - 網絡界面控制器 (NIC) 管理
OS - 已安裝的操做系統管理
::設置系統時間
wmic os where(primary=1) call setdatetime 20070731144642.555555+480
PAGEFILESET - 頁面文件設置管理
::更改當前頁面文件初始大小和最大值
wmic PAGEFILESET set InitialSize="512",MaximumSize="512"
::頁面文件設置到d:\下,執行下面兩條命令
wmic pagefileset create name='d:\pagefile.sys',initialsize=512,maximumsize=1024
wmic pagefileset where"name='c:\\pagefile.sys'" delete
PRODUCT - 安裝包任務管理
::安裝包在C:\WINDOWS\Installer目錄下
::卸載.msi安裝包
wmic PRODUCT where "name='Microsoft .NET Framework 1.1' and Version='1.1.4322'" call Uninstall
::修復.msi安裝包
wmic PRODUCT where "name='Microsoft .NET Framework 1.1' and Version='1.1.4322'" call Reinstall
SERVICE - 服務程序管理
::運行spooler服務
wmic SERVICE where name="Spooler" call startservice
::中止spooler服務
wmic SERVICE where name="Spooler" call stopservice
::暫停spooler服務
wmic SERVICE where name="Spooler" call PauseService
::更改spooler服務啓動類型[auto|Disabled|Manual] 釋[自動|禁用|手動]
wmic SERVICE where name="Spooler" set StartMode="auto"
::刪除服務
wmic SERVICE where name="test123" call delete
SHARE - 共享資源管理
::刪除共享
wmic SHARE where name="e$" call delete
::添加共享
WMIC SHARE CALL Create "","test","3","TestShareName","","c:\test",0
SOUNDDEV - 聲音設備管理
wmic SOUNDDEV list
STARTUP - 用戶登陸到計算機系統時自動運行命令的管理
::查看msconfig中的啓動選項
wmic STARTUP list
SYSDRIVER - 基本服務的系統驅動程序管理
wmic SYSDRIVER list
USERACCOUNT - 用戶賬戶管理
::更改用戶administrator全名爲admin
wmic USERACCOUNT where name="Administrator" set FullName="admin"
::更改用戶名admin爲admin00wmic useraccount where "name='admin" call Rename admin00