echo off
cls
:: by Juan Calderon 09/22
::
:: Developed as an alternative over the manual computer naming of XXXXXX[service tag]
::
:: This batch file will rename the computer using the servivce tag in BIOS.
:: find out what path the batch file is in
:: set batch_path=%~dp0
:: change drive
:: %batch_path:~0,2%
:: crop the last character and cd into it
:: cd %batch_path:~0,-1%
:: clear screen show bitlocker status
:: cls
:: WMIC computersystem where caption=’current_pc_name’ rename new_pc_name
:: pipe machine service tag to serial.txt so that later we can reverse pipe into the variable that used to name the capture file
wmic bios get serialnumber | find /v “SerialNumber” > %temp%/serial.txt
::pipe in serial
set /p serial=<%temp%\serial.txt
:: trim spaces
set serial_temp=%serial: =%
:: store serial
set serial=%serial_temp%
set current_name=%hostname%
@echo.
@echo *************************************************************************************
@echo — Renaming machine from %computername% to XXXXX%serial% —
@echo *************************************************************************************
wmic computersystem where “name=’%computername%'” call rename name=XXXXX%serial%