I want to use (wmic bios get serialnumber) values to set local admin password in Windows 7.
I wrote a small script which has some bugs. Please help to fix it.
@ECHO OFF
set a=wmic bios get serialnumber
net user administrator 123-%a%
pause
I want to use (wmic bios get serialnumber) values to set local admin password in Windows 7.
I wrote a small script which has some bugs. Please help to fix it.
@ECHO OFF
set a=wmic bios get serialnumber
net user administrator 123-%a%
pause
the usual way to get a commands output is a for /f loop:
for /f "delims=" %%a in ('wmic bios get serialnumber /value ^|find "="') do set %%a
echo %serialnumber%
The find is used to a) get the correct line and b) convert wmics output from Unicode to ANSI.
 
    
    This can be considered as duplicate of this. But wmic commands could need additional for loop for better parsing:
 @ECHO OFF
for /f "tokens=* delims=" %%a in ('wmic bios get serialnumber /format:value') do (
    for /f "tokens=* delims=" %%# in ("%%a") do set "%%#"
)
net user administrator 123-%SerialNumber%
pause
