Last active
July 1, 2022 04:25
-
-
Save maciakl/623f2a0dda4ee41c5910e5f32474a65c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
if "%1" == "elevated" goto start | |
powershell -command "Start-Process %~nx0 elevated -Verb runas" | |
goto :eof | |
:start | |
@echo off | |
cls | |
CALL :HEAD | |
CALL :COMPUTERNAME | |
CALL :SERVICETAG | |
SET SERVICETAG=%SERVICETAG:~0,7% | |
echo. | |
echo Computer Name: %COMPUTERNAME% | |
echo Service Tag: %SERVICETAG% | |
echo. | |
echo. | |
choice /M "Rename and reboot [R], or Quit [Q]" /C RQ | |
echo. | |
if %ERRORLEVEL% == 1 ( CALL :RENAME ) | |
if %ERRORLEVEL% == 2 ( goto :eof ) | |
goto :start | |
:HEAD | |
cls | |
echo. | |
echo Rename Helper | |
echo ============= | |
echo. | |
goto :eof | |
:COMPUTERNAME | |
for /f "skip=1" %%i in ('wmic computersystem get name') DO ( | |
SET COMPUTERNAME=%%i | |
goto :eof | |
) | |
:SERVICETAG | |
for /f "skip=1" %%i in ('wmic bios get serialnumber') DO ( | |
SET SERVICETAG=%%i | |
goto :eof | |
) | |
:RENAME | |
powershell -Command "Rename-Computer -NewName %SERVICETAG% -Restart" | |
goto :eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment