WMIC 實例教程

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 Files\Tencent\QQ\QQ.exe"
 
在遠程機器上建立新進程:
wmic /node:192.168.1.10 /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%\\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 where name^="c:\\windows\\system32\\notepad.exe" get CreationDate^,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 where Status='ok' get ScreenHeight,ScreenWidth
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 where caption='filename.exe' get WorkingSetSize,PeakWorkingSetSize
以KB爲單位顯示
@echo off
for /f "skip=1 tokens=1-2 delims= " %%a in ('wmic process where caption^="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% PATH win32_terminalservicesetting WHERE (__Class!="") CALL SetAllowTSConnections 1
 
 
相關文章
相關標籤/搜索