Skip to content

Instantly share code, notes, and snippets.

@hamdymohamedak
Created January 15, 2025 04:55
Show Gist options
  • Select an option

  • Save hamdymohamedak/72ed73ed3f483330f522a3dfa6b3748e to your computer and use it in GitHub Desktop.

Select an option

Save hamdymohamedak/72ed73ed3f483330f522a3dfa6b3748e to your computer and use it in GitHub Desktop.
this file can change the windows username from CMD replace "NEW NAME "with your name , the file run as adminstrator by default
@echo off
:: Check if the script is running as Administrator
openfiles >nul 2>&1
if %errorlevel% neq 0 (
echo This script must be run as Administrator.
echo Restarting the script as Administrator...
powershell -Command "Start-Process cmd -ArgumentList '/c, \"%~f0\"' -Verb runAs"
exit /b
)
:: Get the current username
for /f "tokens=2 delims=\" %%a in ('whoami') do set currentUser=%%a
:: Change the username to "askander"
net user %currentUser% /fullname:"NEW NAME"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment