怎么用BAT或者powershell获取主机名和登录用户保存到TXT文件中,或者用其他什么方式?
2个回答
展开全部
更多追问追答
追问
还要 获取登录用户和IP地址,Mac地址,保存的TXT文件命名用登录用户命名,谢谢
追答
@echo off & title 获取本机简单信息 By 依梦琴瑶
(echo 登录名:%USERNAME%
echo 主机名:%COMPUTERNAME%
for /f "tokens=2 delims==" %%a in ('Wmic NIC Where "NetConnectionID Like '本地连接'" Get MACAddress /value') do set Mac=%%a
echo MAC地址:%Mac%
for /f tokens^=1^,2^ delims^=^"^" %%a in ('wmic nicconfig get IPAddress /value ^| findstr /i "IPAddress=[^]"') do (set "ip=%%b")
echo IP地址:%ip%)>"%USERNAME%.txt"
pause
展开全部
@echo off
rem 获取当前主机名、用户名、IP和MAC
set #=Any question&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$% %z%
cd /d "%~dp0"
for /f "delims=" %%a in ('wmic NICCONFIG where "IPEnabled=True" get IPAddress^,MACAddress /value^|find "="') do set %%a
(echo;computername=%computername%
echo;username=%username%
for /f tokens^=^2^ delims^=^" %%a in ("%IPAddress%") do echo;IP=%%a
echo;MAC=%MACAddress%)>"%username%.txt"
:end
echo;%#% +%$%%$% %z%
pause
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询