I work with a company that repurposes laptops for companies, and we get orders of around 20-100 laptops per order. We install brand new images on them after we refurbish the laptop itself, but we are having problems with writing an automatic naming script. I was tasked with finding a script that can do the following:
- Read the serial number from the bios of the laptop
- Compare this serial number to a spreadsheet or CSV file, and find the serial number there
- Then, find the desired computer name in the column next to the serial number
- Finally, rename the computer using the new name found in the file
It is much easier to write one big spreadsheet file with names and serial numbers, than it is to type each new name in CMD prompt and restarting each computer individually.
So far I have the following script to use the serial number as a variable, if need be:
for /f "skip=1 delims=" %%J in ('wmic bios get serialnumber') do (set serial=%%J
Goto :done)
:done
After we have this script, typing %serial% inputs the serial number specific to that computer.
I also know that the following script will rename the computer, using a variable as the new name:
wmic computersystem where caption='%computername%' rename %variable%
Where %variable% is the variable we will hopefully find in the spreadsheet. I just don't know how to find that new variable (new computer name) that would be found in the spreadsheet. Any help would be greatly appreciated.