Windows WMIC命令使用详解(附实例)

2019-09-19 06:44:54丽君

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:WINDOWSsystem32svchost.exe的
wmic process where "name='svchost.exe' and ExecutablePath<>'C:WINDOWSsystem32svchost.exe'" call Terminate
★★新建notepad进程
wmic process call create notepad

PRODUCT - 安装包任务管理
★★安装包在C:WINDOWSInstaller目录下
★★卸载.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

相关文章 大家在看