15
2022
08

WMIC扩展WMI(Windows Management Instrumentation,Windows管理工具)



推荐点击下面图片,通过本站淘宝优惠价购买:

image.png

https://www.cnblogs.com/hester/p/7566906.html


WMIC扩展WMI(Windows Management Instrumentation,Windows管理工具) ,提供了从命令行接口和批命令脚本执行系统管理的支持。

一、如何使用帮助文档:

1.wmic /?

#################################################################

The following global switches are available:
/NAMESPACE Path for the namespace the alias operate against.
/ROLE Path for the role containing the alias definitions.
/NODE Servers the alias will operate against.
/IMPLEVEL Client impersonation level.
/AUTHLEVEL Client authentication level.
/LOCALE Language id the client should use.
/PRIVILEGES Enable or disable all privileges.
/TRACE Outputs debugging information to stderr.
/RECORD Logs all input commands and output.
/INTERACTIVE Sets or resets the interactive mode.
/FAILFAST Sets or resets the FailFast mode.
/USER User to be used during the session.
/PASSWORD Password to be used for session login.
/OUTPUT Specifies the mode for output redirection.
/APPEND Specifies the mode for output redirection.
/AGGREGATE Sets or resets aggregate mode.
/AUTHORITY Specifies the <authority type> for the connection.
/?[:<BRIEF|FULL>] Usage information.

#################################################################

 

2. wmic nic /?

#################################################################

NIC - Network Interface Controller (NIC) management.

HINT: BNF for Alias usage.
(<alias> [WMIObject] | <alias> [<path where>] | [<alias>] <path where>) [<verb clause>].

USAGE:

NIC ASSOC [<format specifier>]
NIC CREATE <assign list>
NIC DELETE
NIC GET [<property list>] [<get switches>]
NIC LIST [<list format>] [<list switches>]

#################################################################

 

3.wmic nic get    #获取网卡所有信息,如下只列出部分列

 

4.信息筛选

wmic nic where NetEnabled=True get name,speed

 

二、常用操作使用说明

1.PROCESS - 进程管理

::列出进程的核心信息,类似任务管理器
wmic process list brief

::新建notepad进程
wmic process call create notepad

::列出进程的信息
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


2.BIOS - 基本输入/输出服务 (BIOS) 管理

::查看bios版本型号
wmic bios get name,SMBIOSBIOSVersion,manufacturer

3.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

4.CPU - CPU 管理

::查看cpu型号

wmic cpu get name

5.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

6.DESKTOPMONITOR - 监视器管理

::获取屏幕分辨率
wmic DESKTOPMONITOR where Status='ok' get ScreenHeight,ScreenWidth

DISKDRIVE - 物理磁盘驱动器管理

::获取物理磁盘型号大小等
wmic DISKDRIVE get Caption,size,InterfaceType

7.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

8.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"

9.LOGICALDISK - 本地储存设备管理

::获取硬盘系统格式、总大小、可用空间等
wmic LOGICALDISK get name,Description,filesystem,size,freespace

10.NIC - 网络界面控制器 (NIC) 管理

::获取已连接网卡的名字、速率

wmic NIC where NetEnabled=true get Name, Speed

::获取已IP地址网卡的index、caption
wmic nicconfig where IPEnabled="true" get Index, Caption

::设置index =1的网卡,静态IP地址
nicconfig where Index=1 call EnableStatic (“1.2.3.4”), (“255.255.255.0”)

::设置index =1的网卡,采用DHCP方式获取IP地址
nicconfig where Index=1 call EnableDHCP

11.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

12.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

13.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

14.SHARE - 共享资源管理

::删除共享
wmic SHARE where name="e$" call delete

::添加共享
WMIC SHARE CALL Create "","test","3","TestShareName","","c:\test",0

SOUNDDEV - 声音设备管理
wmic SOUNDDEV list

15.STARTUP - 用户登录到计算机系统时自动运行命令的管理

::查看msconfig中的启动选项
wmic STARTUP list

SYSDRIVER - 基本服务的系统驱动程序管理
wmic SYSDRIVER list

16.USERACCOUNT - 用户帐户管理

::更改用户administrator全名为admin
wmic USERACCOUNT where name="Administrator" set FullName="admin"

::更改用户名admin为admin00
wmic useraccount where "name='admin" call Rename admin00

 


本文链接:https://hqyman.cn/post/2653.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:





休息一下,本站随机推荐观看栏目:


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

您的IP地址是: