How to save a logfile with the serial number of a computer?

时间:2016-08-30 04:47:02

标签: batch-file

So this is what I have so far in my batch file. What I'm looking to do, is take the file that is created from the last line, 'serialnumber.txt' and rename it to the actual serial number of the computer. Maybe using the 'wmic bios get serialnumber' in some way?

wmic csproduct get identifyingnumber > %~d0\serial2.txt
%WINDIR%\SYSTEM32\msinfo32.exe /report %~d0\info2.txt
copy /b %~d0\serial2.txt + %~d0\info2.txt %~d0\serialnumber.txt

1 个答案:

答案 0 :(得分:0)

SomethingDark 的评论相关,您正在寻找类似的内容:

如何使用计算机的序列号保存日志文件?

@echo off
Call :GetSerialNumber
echo %SerialNumber% & pause
%WINDIR%\SYSTEM32\msinfo32.exe /report "%~d0\%SerialNumber%.txt"
Start "" "%~d0\%SerialNumber%.txt"
Exit
::***********************************************
:GetSerialNumber
for /f "tokens=2 delims==" %%a in ('
    wmic csproduct get identifyingnumber /value
') do for /f "delims=" %%b in ("%%a") do (
    Set "SerialNumber=%%b" 
)
exit /b
::***********************************************