Piping contents of Serial Number into Variabl

Microsoft Windows 7 professional - upgra...
February 10, 2011 at 10:25:01
Specs: Windows 7
Hello,
I am trying to pipe the contents of :
wmic bios get serialnumber
and store it into a variable called %SERIAL%.
I've tried multiple variations of :
SET SERIAL | wmic bios get serialnumber and
SET SERIAL > wmic bios get serialnumber
but have not been able to make it work.
The final output of what I want is a file called C:\Temp\%SERIAL%.txt
with contents of the %MAC_ADDRESS%.
thanks,

See More: Piping contents of Serial Number into Variabl

Report •


#1
February 10, 2011 at 15:00:12
for /F "delims=" %%j in ('wmic bios get serialnumber') do set SERIAL=%%j


Report •

#2
February 11, 2011 at 06:25:32
Thanks for the response.
When I run that command, I get a "in was unexpected at this time" error.

Report •

#3
February 11, 2011 at 07:43:58
Did you run the command inside a batch script?

Report •

Related Solutions

#4
February 11, 2011 at 08:36:43
yes,,,
it does create the variable, but when I look at the variables, I see:

Serial=

and nothing at the end.
Thanks again for the help.


Report •

#5
February 11, 2011 at 09:04:45
Please, in your post #2 you said you got an error message. Then you say the variable is empty, so I assume now you can run the command (how?).

May you post the output of your program to catch serial number typing it at prompt?


Report •

#6
February 11, 2011 at 09:32:03
oops.. yes, sorry...
At first I was just running it via command line,, then I did as you suggested is to add it to a batch file, but that's when I got the empty variable.

Report •

#7
February 11, 2011 at 13:17:33
If you run at prompt

wmic bios get serialnumber

and post what displayed I am sure we can fix the issue.

Report •

#8
February 11, 2011 at 17:15:18
As someone with Win7, I'm going to jump in here to speed things along:

IVO: post what displayed
Note: \n denotes CR/LF.

SerialNumber          \n
System Serial Number  \n

Basically, there's a blank line at the end:
C:\>for /F "delims=" %j in ('wmic bios get serialnumber') do @echo set SERIAL=%j
set SERIAL=SerialNumber
set SERIAL=System Serial Number
set SERIAL=

How To Ask Questions The Smart Way


Report •

#9
February 12, 2011 at 06:38:14
Well, Razor2.3, so following what you pointed out

@echo off
for /F "skip=1 delims=" %%j in ('wmic bios get serialnumber') do (
  set SERIAL=%%j
  goto :DONE
)
:DONE
echo  SERIAL=%SERIAL%

Obviously a batch script (with echo disabled as my way...).

Report •

#10
February 14, 2011 at 05:57:26
I added that to the batch file and it worked, worked well.
Thanks to both of you for your help, it saved me a lot of anguish..
:o)

Report •


Ask Question