wmic获取进程名称以及可执行路径:
wmicprocessgetname,executablepath
wmic删除指定进程(根据进程名称):
wmicprocesswherename=qq.execallterminate
或者用
wmicprocesswherename=qq.exedelete
wmic删除指定进程(根据进程pid):
wmicprocesswherepid=123delete
wmic创建新进程
wmicprocesscallcreatec:\programfiles\tencent\qq\qq.exe
在远程机器上创建新进程:
wmic/node:192.168.1.10/user:administrator/password:123456processcallcreatecmd.exe
关闭本地计算机
wmicprocesscallcreateshutdown.exe
重启远程计算机
wmic/node:192.168.1.10/user:administrator/password:123456processcallcreateshutdown.exe-r-f-m
更改计算机名称
wmiccomputersystemwherecaption='%computername%'callrenamenewcomputername
更改帐户名
wmicuseraccountwherename='%username%'callrenamenewusername
wmic结束可疑进程(根据进程的启动路径)
wmicprocesswherename='explorer.exe'andexecutablepath<>'%systemdrive%\\windows\\explorer.exe'delete
wmic获取物理内存
wmicmemlogicalgettotalphysicalmemory|find/i/vt
wmic获取文件的创建、访问、修改时间
代码如下:
@echooff
for/fskip=1tokens=1,3,5delims=.%%ain('wmicdatafilewherename^=c:\\windows\\system32\\notepad.exegetcreationdate^,lastaccessed^,lastmodified')do(
seta=%%a
setb=%%b
setc=%%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/fskip=1tokens=1*%iin('wmicdatafilewherefilename='qq'andextension='exe'getdrive^,path')do(setqpath=%i%j&@echo%qpath:~0,-3%)
获取屏幕分辨率wmicdesktopmonitorwherestatus='ok'getscreenheight,screenwidth
wmicpagefilesetsetinitialsize=512,maximumsize=512
设置虚拟内存到e盘,并删除c盘下的页面文件,重启计算机后生效
wmicpagefilesetcreatename=e:\\pagefile.sys,initialsize=1024,maximumsize=1024
wmicpagefilesetwherename='c:\\pagefile.sys'delete
获得进程当前占用的内存和最大占用内存的大小:
wmicprocesswherecaption='filename.exe'getworkingsetsize,peakworkingsetsize
以kb为单位显示
代码如下:
@echooff
for/fskip=1tokens=1-2delims=%%ain('wmicprocesswherecaption^=conime.exegetworkingsetsize^,peakworkingsetsize')do(
set/am=%%a/1024
set/amm=%%b/1024
echo进程conime.exe现在占用内存:%m%k;最高占用内存:%mm%k
)
pause
远程打开计算机远程桌面
wmic/node:%pcname%/user:%pcaccount%pathwin32_terminalservicesettingwhere(__class!=)callsetallowtsconnections1
检测是否插入u盘的批处理
代码如下:
@echooff
((wmiclogicaldiskwheredrivetype=2getname|find无可用范例)>nul2>nul)||for/fskip=1tokens=*delims=%%iin('wmiclogicaldiskwheredrivetype=2getname')doechou盘盘符是%%i
pause
rem查看cpu
wmiccpulistbrief
rem查看物理内存
wmicmemphysicallistbrief
rem查看逻辑内存
wmicmemlogicallistbrief
rem查看缓存内存
wmicmemcachelistbrief
rem查看虚拟内存
wmicpagefilelistbrief
rem查看网卡
wmicniclistbrief
rem查看网络协议
wmicnetprotocallistbrief
【例】将当前系统bios,cpu,主板等信息输出到一个html网页文件,命令如下:
::得到系统信息.bat,运行bat文件即可
::系统信息输出到html文件,查看帮助:wmic/?
::wmic[系统参数名]list[brief|full]/format:hform>|>>[文件名]
wmicbioslistbrief/format:hform>pcinfo.html
wmicbaseboardlistbrief/format:hform>>pcinfo.html
wmiccpulistfull/format:hform>>pcinfo.html
wmicoslistfull/format:hform>>pcinfo.html
wmiccomputersystemlistbrief/format:hform>>pcinfo.html
wmicdiskdrivelistfull/format:hform>>pcinfo.html
wmicmemlogicallistfull/format:hform>>pcinfo.html
pcinfo.html
2025国考·省考课程试听报名