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:
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.
The following is the code that I used for the problem that I was having.
for /f "tokens=2 delims==" %%J in ('wmic bios get serialnumber /value') do set serial=%%J
Find /I "%serial%" {Location of file} > {Location of confirmation file}
For /f "tokens=1,2* delims=," %%G in ({Location of confirmation file}) do set HN=%%H
wmic computersystem where caption='%computername%' rename %HN%`
Looks complicated, but by lines of text they do the following:
1) Finds the serial number from the bios
2) Finds the line in the CSV file and outputs the whole line into a text document
3) Sets the desired name from the text document as a variable
4) Renames the computer name to this desired variable name