UUID to be stored in file

2019-08-16 00:35发布

问题:

I am trying to get the UUID of the system and to store it in a file. using the command wmic csproduct get UUID I am getting the output file as (UUID some spaces then value) i.e UUID 4C4C4544-0031-5910-8048-B1C04F565331.

But I need the value alone (4C4C4544-0031-5910-8048-B1C04F565331) in my output file.

回答1:

filter the line, you need:

wmic csproduct get uuid |find "-" >file.txt

EDIT in reply to your comment:

there is a more general way to get what you want:

for /f %%i in ('wmic cpu get ProcessorID /value^|find "="') do set id=%%i