标题: [系统相关] [分享]批处理获取用户名、计算机名、BIOS序列号生成csv文件 [打印本页]
作者: Batcher 时间: 2022-4-26 13:54 标题: [分享]批处理获取用户名、计算机名、BIOS序列号生成csv文件
【问题描述】
生成以下格式的csv文件
1,2,3
"Administrator","DESKTOP-BatHome","123456654321"
作者: Batcher 时间: 2022-4-26 13:55
【解决方案】- @echo off
- (echo 1,2,3
- for /f "tokens=2 delims==" %%i in ('wmic bios list full ^|findstr "SerialNumber"') do (
- for /f %%j in ("%%i") do (
- echo "%username%","%computername%","%%j"
- )
- ))>"a.csv"
复制代码
作者: Batcher 时间: 2022-4-26 16:09
补充提问:该怎么第四列显示IP地址?- @echo off
- (echo 1,2,3,4
- for /f "tokens=2 delims==" %%i in ('wmic bios list full ^|findstr "SerialNumber"') do (
- for /f %%j in ("%%i") do (
- for /f "tokens=16" %%k in ('ipconfig ^|find /i "ipv4"') do (
- echo "%username%","%computername%","%%j","%%k"
- )
- )
- ))>"a.csv"
复制代码
作者: Batcher 时间: 2022-4-26 21:53
- @echo off
- setlocal enabledelayedexpansion
- set "OutFile=a.csv"
- >"%OutFile%" echo 计算机名,域用户名,序列号,IP地址,子网掩码,网关,MAC地址,操作系统,WIN7型号,WIN10型号,出厂日期
- for /f "tokens=2 delims==" %%i in ('wmic bios list full ^| findstr "SerialNumber"') do (
- for /f %%j in ("%%i") do (
- set "SN=%%j"
- )
- )
- for /f "tokens=16" %%i in ('ipconfig ^| findstr /i "ipv4"') do set "IP=%%i"
- for /f "tokens=15" %%i in ('ipconfig ^| findstr /i "子网掩码"') do set "Mask=%%i"
- for /f "tokens=15" %%i in ('ipconfig ^| findstr /i "默认网关"') do set "Gateway=%%i"
- for /f %%i in ('getmac /nh ^| findstr "..-..-..-..-..-.."') do set "MAC=%%i"
- for /f "tokens=1* delims==" %%i in ('wmic os get caption /value ^| findstr "="') do (
- for /f "delims=" %%k in ("%%j") do (
- set "CaptionOS=%%k"
- )
- )
- for /f "tokens=1* delims==" %%i in ('wmic csproduct get name /value ^| findstr "="') do (
- for /f "delims=" %%k in ("%%j") do (
- set "ProductName=%%k"
- )
- )
- for /f "tokens=1* delims==" %%i in ('wmic csproduct get version /value ^| findstr "="') do (
- for /f "delims=" %%k in ("%%j") do (
- set "ProductVersion=%%k"
- )
- )
- for /f "tokens=2 delims==" %%i in ('wmic bios get releasedate /value ^| findstr "="') do set "TS=%%i"
- set "MyDate=!TS:~0,4!年!TS:~4,2!月!TS:~6,2!日"
- >>"%OutFile%" echo "%computername%","%username%","!SN!","!IP!","!Mask!","!Gateway!","!MAC!","!CaptionOS!","!ProductName!","!ProductVersion!","!MyDate!"
复制代码
作者: yyz219 时间: 2022-4-26 22:33
回复 4# Batcher
收藏备用,谢谢分享
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |