写了一个读取系统信息的程序,生成mac.csv,可是生成的结果是竖排的,可否横排,各位老大帮忙,谢谢~复制代码
- @echo off & setlocal enabledelayedexpansion
- for /f "tokens=2 delims==" %%a in ('wmic csproduct get Vendor /value ^| findstr /i "Vendor"') do echo 制造商:%%~a >>d:\mac.csv
- for /f "tokens=2 delims==" %%a in ('wmic csproduct get Name /value ^| findstr /i "Name"') do echo 电脑型号:%%~a >>d:\mac.csv
- for /f "tokens=2 delims==" %%a in ('wmic os get caption /value ^| findstr /i "caption"') do echo 操作系统:%%~a >>d:\mac.csv
不知道为什么,我好像没法把他写到D:\mac.csv,只能用相对路径了。。。复制代码
- @echo off & setlocal enabledelayedexpansion
- echo 制造商 电脑型号 操作系统>mac.csv
- for /f "tokens=2 delims==" %%a in ('wmic csproduct get Vendor /value ^| findstr /i "Vendor"') do set "value=%%~a"
- for /f "tokens=2 delims==" %%a in ('wmic csproduct get Name /value ^| findstr /i "Name"') do set "value=%value% %%~a"
- for /f "tokens=2 delims==" %%a in ('wmic os get caption /value ^| findstr /i "caption"') do set "value=%value% %%~a"
- echo %value%>>mac.csv
- pause
复制代码
- @echo off & setlocal enabledelayedexpansion
- echo 制造商,电脑型号,操作系统>mac.csv
- for /f "tokens=2 delims==" %%a in ('wmic csproduct get Vendor /value ^| findstr /i "Vendor"') do set "value=%%~a"
- for /f "tokens=2 delims==" %%a in ('wmic csproduct get Name /value ^| findstr /i "Name"') do set "value=%value%,%%~a"
- for /f "tokens=2 delims==" %%a in ('wmic os get caption /value ^| findstr /i "caption"') do set "value=%value%,%%~a"
- echo %value%>>mac.csv
- pause
再加个物理地址呢复制代码
- for /f "tokens=1,3 delims=," %%i in ('getmac /v /nh /fo:csv ^| findstr
- "..-..-..-..-..-.."') do (
- echo %%i %%j
- )
给出一个近似的解决方案。复制代码
- "无线网络连接" "balabalabala"
- "本地连接" "balabalabala"
- "Bluetooth 网络连接" "balabalabala"
复制代码
- @echo off & setlocal enabledelayedexpansion
- set "type=制造商,电脑型号,操作系统"
- for /f "tokens=2 delims==" %%a in ('wmic csproduct get Vendor /value ^| findstr /i "Vendor"') do set "value=%%~a"
- for /f "tokens=2 delims==" %%a in ('wmic csproduct get Name /value ^| findstr /i "Name"') do set "value=%value%,%%~a"
- for /f "tokens=2 delims==" %%a in ('wmic os get caption /value ^| findstr /i "caption"') do set "value=%value%,%%~a"
- for /f "tokens=1,3 delims=," %%i in ('getmac /v /nh /fo:csv ^| findstr "..-..-..-..-..-.."') do (
- set type=!type!,%%i
- set value=!value!,%%j
- )
- echo %type%>mac.csv
- echo %value%>>mac.csv
- pause
接下来,请仔细阅读代码,自行修改。(别告诉我你不会csv格式)
"无线网络连接" "balabalabala"
"本地连接" "balabalabala"
"Bluetooth 网络连接" "balabalabala"
在问问,如果加了判断语句,为啥得到的文档里头只显示复制代码
- @echo off & setlocal enabledelayedexpansion
- if 1 lss 2 (
- set "type=制造商,电脑型号,操作系统"
- for /f "tokens=2 delims==" %%a in ('wmic csproduct get Vendor /value ^| findstr /i "Vendor"') do set "value=%%~a"
- for /f "tokens=2 delims==" %%a in ('wmic csproduct get Name /value ^| findstr /i "Name"') do set "value=%value%,%%~a"
- for /f "tokens=2 delims==" %%a in ('wmic os get caption /value ^| findstr /i "caption"') do set "value=%value%,%%~a"
- for /f "tokens=1,3 delims=," %%i in ('getmac /v /nh /fo:csv ^| findstr "..-..-..-..-..-.."') do (
- set type=!type!,%%i
- set value=!value!,%%j
- )
- echo %type%>mac.csv
- echo %value%>>mac.csv
- ) else (
- echo ok
- )
- pause
ECHO 处于关闭状态。
ECHO 处于关闭状态。
欢迎光临 批处理之家 (http://www.bathome.net/) | Powered by Discuz! 7.2 |