首页 > 1 软件使用心得 > WMIC入门

WMIC入门

2012年6月23日 AEROFISH 2,171 views 发表评论 阅读评论

WMIC——Windows管理规范命令行,英文全称Windows Management Instrumentation Command-line。
最近刚学习了这个,原来Windows还有这么好用的管理工具。

下面介绍我的入门学习心得。

1、WMIC操作需要Administrator权限。

2、WMIC执行模式分交互和非交互两种。
交互模式。在命令提示符下或通过“运行”菜单只输入WMIC,进入WMIC的交互模式:wmic:root\cli>。
非交互模式。在命令提示符下或通过“运行”菜单只输入WMIC+参数,直接运行命令。

3、查看所有命令:在交互模式中输入:/?

4、查看单个命令的详细信息:在交互模式中输入:命令 /?

举例:
依次在交互模式中使用以下命令看有什么不同:
/?
process /?
process
process get
process get caption,commandline
process get /?
process list /?

这里只介绍最简单的用法,更详细当你还是要去看专门的教材。

==================

附1:命令提示符操作心得——复制粘贴的方法:
开始菜单输入cmd,进入命令提示符。
在该窗口栏右键选“属性”,勾选“快速编辑模式”,这样就能进行复制、粘贴操作。
复制:选中内容,点鼠标右键;
粘贴:光标移动适当位置,点鼠标右键。

==================

附2:WMIC命令收集

查看bios版本型号
wmic bios get Manufacturer,Name

查看系统启动选项boot的内容
wmic COMPUTERSYSTEM get SystemStartupOptions

查看工作组/域
wmic computersystem get domain

更改计算机名abc为123
wmic computersystem where "name='abc'" call rename 123

更改工作组WORKGROUP为MyGroup
wmic computersystem where "name='WORKGROUP'" call joindomainorworkgroup "","","MyGroup",1
 
查看cpu型号
wmic cpu get name
 
查找d盘下test目录(不包括子目录)下的abc.txt文件
wmic datafile where "drive='d:' and path='\\test\\' and FileName='abc' and Extension='txt'" list

查找d盘下所有目录和子目录下的abc.txt文件,且文件小于1K(不建议使用,查询时间很长)
wmic datafile where "drive='d:' and FileName='abc' and Extension='txt' 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

获取屏幕分辨率
wmic DESKTOPMONITOR where Status='ok' get ScreenHeight,ScreenWidth
 
获取物理磁盘型号大小等
wmic DISKDRIVE get Caption,size,InterfaceType
 
获取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

查找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"

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

设置系统时间
wmic os where(primary=1) call setdatetime 20070731144642.555555+480

更改当前页面文件初始大小和最大值,重启计算机后生效
wmic PageFileSet set InitialSize="512",MaximumSize="512"

设置虚拟内存到E盘,并删除C盘下的页面文件,重启计算机后生效
wmic PageFileSet create name="E:\\pagefile.sys",InitialSize="1024",MaximumSize="1024"
wmic PageFileSet where "name='C:\\pagefile.sys'" delete
 
列出进程的核心信息,类似任务管理器
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

获取进程名称以及可执行路径:
wmic process get name,executablepath

删除指定进程(根据进程名称):
wmic process where name="qq.exe" call terminate
或者用
wmic process where name="qq.exe" delete

删除指定进程(根据进程PID):
wmic process where pid="123" delete

创建新进程
wmic process call create "C:\Program Files\Tencent\QQ\QQ.exe"
wmic process call create notepad

在远程机器上创建新进程:(2003系统)
wmic /node:192.168.1.10 /user:administrator /password:123456 process call create cmd.exe

关闭本地计算机
wmic process call create shutdown.exe

重启远程计算机 (2003系统)
wmic /node:192.168.1.10/user:administrator /password:123456 process call create "shutdown.exe -r -f -m"

结束可疑进程(根据进程的启动路径)
wmic process where "name='explorer.exe' and executablepath<>C:\\WINDOWS\\windows\\explorer.exe'" delete

获得进程当前占用的内存和最大占用内存的大小:
wmic process where caption='filename.exe' get WorkingSetSize,PeakWorkingSetSize

安装包在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

运行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

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

添加共享
wmic SHARE CALL Create "","test","3","TestShareName","","c:\test",0
 
声音设备管理
wmic SOUNDDEV list
 
查看msconfig中的启动选项
wmic STARTUP list
 
基本服务的系统驱动程序管理
wmic SYSDRIVER list
 
更改用户administrator全名为admin
wmic USERACCOUNT where name="Administrator" set FullName="admin"

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

wmic 操作计算机名称和用户帐户
更改计算机名称
wmic computersystem where "caption='%ComputerName%'" call rename newcomputername

更改帐户名
wmic USERACCOUNT where "name='%UserName%'" call rename newUserName

获取物理内存
wmic memlogical get TotalPhysicalMemory


本文对我无帮助,减1分本文对我有帮助,加1分 (本文对您有帮助吗?)
Loading ... Loading ...

分类: 1 软件使用心得 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.