您的位置:首页 > 其它

WMIC 超级命令行管理工具

2011-08-23 17:47 513 查看
wmic 获取进程名称以及可执行路径:

wmic process get name,executablepath

wmic 删除指定进程(根据进程名称):

wmic process where name="qq.exe" call terminate

或者用

wmic process where name="qq.exe" delete

wmic 删除指定进程(根据进程PID):

wmic process where pid="123" delete

wmic 创建新进程

wmic process call create "C:\ProgramFiles\Tencent\QQ\QQ.exe"

在远程机器上创建新进程:

wmic /node:192.168.1.10 /user:administrator /password:123456process call create cmd.exe

关闭本地计算机

wmic process call create shutdown.exe

重启远程计算机

wmic /node:192.168.1.10/user:administrator /password:123456 processcall create "shutdown.exe -r -f -m"

更改计算机名称

wmic computersystem where "caption='%ComputerName%'" call renamenewcomputername

更改帐户名

wmic USERACCOUNT where "name='%UserName%'" call renamenewUserName

wmic 结束可疑进程(根据进程的启动路径)

wmic process where "name='explorer.exe' andexecutablepath<>'%SystemDrive%\\windows\\explorer.exe'"delete

wmic 获取物理内存

wmic memlogical get TotalPhysicalMemory|find /i /v "t"

wmic 获取文件的创建、访问、修改时间

@echo off

for /f "skip=1 tokens=1,3,5 delims=. " %%a in ('wmic datafile wherename^="c:\\windows\\system32\\notepad.exe" getCreationDate^,LastAccessed^,LastModified') do (

set a=%%a

set b=%%b

set c=%%c

echo 文件: c:\windows\system32\notepad.exe

echo.

echo 创建时间: %a:~0,4% 年 %a:~4,2% 月 %a:~6,2% 日 %a:~8,2% 时 %a:~10,2% 分%a:~12,2% 秒

echo 最后访问: %b:~0,4% 年 %b:~4,2% 月 %b:~6,2% 日 %b:~8,2% 时 %b:~10,2% 分%b:~12,2% 秒

echo 最后修改: %c:~0,4% 年 %c:~4,2% 月 %c:~6,2% 日 %c:~8,2% 时 %c:~10,2% 分%c:~12,2% 秒

)

echo.

pause

wmic 全盘搜索某文件并获取该文件所在目录

for /f "skip=1 tokens=1*" %i in ('wmic datafile where"FileName='qq' and extension='exe'" get drive^,path') do (set"qPath=%i%j"&@echo %qPath:~0,-3%)

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

wmic PageFileSet setInitialSize="512",MaximumSize="512"

设置虚拟内存到E盘,并删除C盘下的页面文件,重启计算机后生效

wmic PageFileSet createname="E:\\pagefile.sys",InitialSize="1024",MaximumSize="1024"

wmic PageFileSet where "name='C:\\pagefile.sys'"delete


获得进程当前占用的内存和最大占用内存的大小:


wmic process wherecaption='filename.exe' getWorkingSetSize,PeakWorkingSetSize


以KB为单位显示


@echo off

for /f "skip=1 tokens=1-2 delims= " %%a in ('wmic process wherecaption^="conime.exe" get WorkingSetSize^,PeakWorkingSetSize') do(

set /a m=%%a/1024

set /a mm=%%b/1024

echo 进程conime.exe现在占用内存:%m%K;最高占用内存:%mm%K

)

pause


远程打开计算机远程桌面


wmic /node:%pcname% /USER:%pcaccount% PATHwin32_terminalservicesetting WHERE (__Class!="") CALLSetAllowTSConnections 1

检测是否插入U盘的批处理

@echo off

用WMIC的时候,有时候需要模糊查询,找了许久终于找到了参数,下面就是一个例子:service where "caption like '%wireless%'"list
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: