WMIC和驱动器序列号的批次问题 [英] Batch issue with wmic and drive serial number
本文介绍了WMIC和驱动器序列号的批次问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
整天忙碌而没有结果,需要从批处理文件中为我的硬盘驱动器序列设置一个变量.当我从批处理"wmic path win32_physicalmedia get SerialNumber/format:csv"
运行此命令时,结果为:
Been working on this all day with no results, need to set a variable from a batch file for my hard drive serial. When I run this command from a batch "wmic path win32_physicalmedia get SerialNumber /format:csv"
it gives results as:
Node,SerialNumber
WORK-PC, S1DHNSAF323341Z
WORK-PC,
只需要序列号打印出"S1DHNSAF323341Z"即可.然后,将其放在带有wmic的For语句中,如下所示,但没有输出.请帮忙,谢谢您的帮助.
Only need the serial to print out "S1DHNSAF323341Z" I then put it in a For statement with wmic as below but no output.. Please help, thanks for the help..Bill
For /F "skip=2 tokens=2 delims=," %%A in ('WMIC Path Win32_physicalmedia Get SerialNumber /FORMAT:csv') Do Set HDSerial=%%A
echo. %HDSerial%
推荐答案
尝试一下:
@echo off
setlocal
For /F "tokens=2 delims==" %%A in ('WMIC Path Win32_physicalmedia Get SerialNumber /value^|find "="') do (
for %%B in (%%A) do (echo %%B)
)
这篇关于WMIC和驱动器序列号的批次问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文