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

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

USERACCOUNT - 用户帐户管理
★★更改用户administrator全名为admin
wmic USERACCOUNT where name="Administrator" set FullName="admin"
★★更改用户名admin为admin00
wmic useraccount where "name='admin" call Rename admin00


================================================获取补丁信息
★★查看当前系统打了哪些补丁
/node:legacyhost qfe get hotfixid

查看CPU当前的速度
★★cpu当前的速度
wmic cpu get CurrentClockSpeed

远程计算机的远程桌面连接
★★WMIC命令开启远程计算机的远程桌面连接
执行wmic /node:192.168.1.2 /USER:administrator
PATH win32_terminalservicesetting WHERE (__Class!="") CALL SetAllowTSConnections 1
具体格式:
wmic /node:"[full machine name]" /USER:"[domain][username]"
PATH win32_terminalservicesetting WHERE (__Class!="") CALL SetAllowTSConnections 1
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:Program FilesTencentQQQQ.exe"

在远程机器上创建新进程:
wmic /node:192.168.201.131 /user:administrator /password:123456 process call create cmd.exe

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

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

更改计算机名称
wmic computersystem where "caption='%ComputerName%'" call rename newcomputername

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

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

wmic process where "name='explorer.exe' and executablepath<>'%SystemDrive%windowsexplorer.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 where name^="c:windowssystem32notepad.exe" get CreationDate^,LastAccessed^,LastModified') do (
set a=%%a
set b=%%b
set c=%%c
echo 文件: c:windowssystem32notepad.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 where Status='ok' get ScreenHeight,ScreenWidth

相关文章 大家在看