查看計算機名
hostname
![]()
查看系統資訊
systeminfo

查看環境變數
set

查看進城資訊
tasklist

終止行程
taskkill


獲取系統補丁情況
wmic qfe list

獲取系統注冊的服務資訊
sc query state=all #cmd 命令

查看當前電腦網卡的ip資訊、DNS資訊、DHCP服務器資訊等
ipconfig /all

顯示 DNS 決議程式快取的內容
ipconfig /displaydns

查看網路連接情況
netstat /bnao

查看網路連接路由表
netstat -r

查看局網內計算機
net view
net use #查看映射
net view /domain
net user /domain
net user %usename% /domain

查看當前登錄用戶
whoami
![]()
net accounts

查看共享
net share

添加共享
net share name$=c:\ /unlimited

查看計算機全部用戶
net user

查看win10 用戶
net user win10

查看本地用戶組資訊
net localgroup

net user a a /add #添加帳戶 a 密碼 a
net user #查看帳戶
net user a 查看帳戶 a

#將帳戶 a 添加到超級管理員組
net localgroup administrators a /add

查看arp地址決議協議
arp -a

查看任務資訊
schtasks

域操作
net group "domain controllers" /domain
net user usename /active:yes /domain
wmic 命令
查看IP和MAC地址
wmic nicconfig get ipaddress,macaddress

查看計算機名和登錄用戶
wmic computersystem get username
![]()
查看最后登錄情況
wmic netlogin get name,lastlogon

查看系統行程資訊(包含啟動命令,檔案路徑)
wmic process get caption,executablepath,commandline

結束一個行程(可根據行程對應的PID--未成功 55555)
wmic process where name="calc.exe" delete
wmic process where name="calc.exe" terminate
wmic process where pid="123" delete
查看系統版本
wmic os get name,servicepackmajorversion

查看系統已安裝軟體資訊
wmic product get name,version

卸載軟體
wmic product where name="name" call uninstall /nointeractive

查詢共享
wmic share get /all

查看日志檔案
wmic nteventlog get path,filename,writeable

打開遠程連接--win10-我沒成功
wmic /node:"machinename\user" path Win32_TerminalServiceSetting where AllowTSConnections="0" call SetAllowTSConnections "1"
![]()
WMIC擴展WMI(Windows Management Instrumentation,Windows管理規范) ,提供了從命令列介面和批命令腳本執行系統管理的支持,為WMI名稱空間提供了一個強大的、友好的命令列介面,
wmic process一種實際用法,用于判斷查詢是否已啟動某個應用的java程式行程,可用于配合zabbix的自定義監控.
wmic process where name="java.exe" get commandline 2>nul | find "appKey" 1>nul 2>nul && echo 1 || echo 0
含義為:如果windows下啟動了 "appKey" 為關鍵字名字的jar包主程式,命令回傳1;若沒有啟動或者不存在則回傳0
===============================
netstat -an -b -o //獲取行程名稱 埠 pid
wmic process list brief >> d:\process.txt //獲取行程摘要資訊寫入檔案
結束一個行程(可根據行程對應的PID)
wmic process where name="notepad.exe" delete
wmic process where name="notepad.exe" terminate
wmic process where pid="123" delete
wmic path win32_process where "name='notepad.exe'" delete
創建一個行程
wmic process call create "c:\windows\system32\calc.exe"
查詢行程的啟動路徑(將得到的資訊輸出)
wmic process get name,executablepath,processid
wmic /output:c:\process.html process get processid,name,executablepath /format:htable.xsl
查詢指定行程的資訊
wmic process where name="notepad.exe" get name,executablepath,processid
在遠程計算上創建行程
wmic /node:192.168.8.10 /user:administrator /password:xiongyefeng process call create "c:\windows\notepad.exe"
查詢遠程計算機上的行程串列
wmic /node:192.168.8.10 /user:administrator /password:xiongyefeng process get name,executablepath,processid
將獲得到的遠程計算機行程串列保存到本地
wmic/output:c:\process.html /node:192.168.8.10 /user:administrator/password:xiongyefeng process get processid,name,executablepath/format:htable.xsl
結束遠程計算上的指定行程
wmic /node:192.168.8.10 /user:administrator /password:xiongyefeng process where name="notepad.exe" delete
重啟遠程計算機
wmic /node:192.168.8.10 /user:administrator /password:xiongyefeng process call create "shutdown -r -f"
關閉遠程計算機
wmic /node:192.168.8.10 /user:administrator /password:xiongyefeng process call create "shutdown -s -f"
高級應用:
結束可疑的行程
wmic process where "name='explorer.exe' and executablepath <> '%systemdrive%\\windows\\explorer.exe'" delete
wmicprocess where "name='svchost.exe' and executablepath <>'%systemdrive%\\windows\\system32\\svchost.exe'" call terminate
查看磁盤的屬性
wmic logicaldisk list brief
根據磁盤的型別查看相關屬性
wmic logicaldisk where drivetype=3 list brief
使用get引數來獲得自己想要參看的屬性
wmic logicaldisk where drivetype=3 get deviceid,size,freespace,description,filesystem
只顯示c盤的相關資訊
wmic logicaldisk where name="c:" get deviceid,size,freespace,description,filesystem
更改卷標的名稱
wmic logicaldisk where name="c:" set volumename=lsxq
獲得U盤的盤符號
wmic logicaldisk where drivetype='2' get deviceid,description
::查看bios版本型號
wmic bios get Manufacturer,Name
COMPUTERSYSTEM - 計算機系統管理
::查看系統啟動選項,boot的內容
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
PROCESS - 行程管理
::列出行程的核心資訊,類似任務管理器
wmic process list brief
::結束svchost.exe行程,路徑為非C:\WINDOWS\system32\svchost.exe的
wmic process where "name='svchost.exe' and ExecutablePath<>'C:\\WINDOWS\\system32\\svchost.exe'" call Terminate
::新建notepad行程
wmic process call create notepad
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為admin00
wmic useraccount where "name='admin" call Rename admin00
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/301442.html
標籤:其他
上一篇:APP安全檢測解決方案淺析
