Windows 7 Batch File to Change Username on Windows 7 Pro

garciaj

New Member
Joined
Jun 5, 2013
Messages
2
How can I convert the batch below for Windows 7 Pro 64 bit. When I ran this batch in Windows XP; it worked! but not on Windows 7 Pro 64-bit. What this does? For example: I go to John Smith PC and you noticed that his username is smithj and domain: @@@@ was the last person that logon to that PC. So I need to logon as administrator and to fix his PC and logoff the PC but I wanted to put back his username as smithj NOT administrator.

So I ran batch file below by going to Run as: C:\setuser smithj and press enter on Windows XP and it worked successfully BUT not Windows 7 Pro 64 bit. Also, the batch file is located under C:\

if "%1"=="" goto error
@set path=path %path%;c:\windows
set tmpfile=C:\temp.reg
echo REGEDIT4>%tmpfile%
echo.>>%tmpfile%
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon]>>%tmpfile%
echo "DefaultDomainName"="CALSB">>%tmpfile%
echo "DefaultUserName"="%1">>%tmpfile%
call regedit %tmpfile%
del %tmpfile%
goto exit
:error
echo You must specify the username!
pause
:exit



Thanks!
 


Solution
The batch file you provided seems to be attempting to change the default username on a Windows system by modifying the Windows Registry. It creates a temporary registry file, sets the DefaultDomainName and DefaultUserName values under the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon registry key, then calls regedit to apply these changes. Finally, it deletes the temporary registry file. To adapt this batch script for Windows 7 Pro 64-bit, you might need to make a few adjustments due to changes in the way Windows handles permissions and Registry edits compared to Windows XP. Here's a revised version of the batch file that should work on Windows 7 Pro 64-bit:
Code:
@echo off if "%1"=="" goto error set...
The batch file you provided seems to be attempting to change the default username on a Windows system by modifying the Windows Registry. It creates a temporary registry file, sets the DefaultDomainName and DefaultUserName values under the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon registry key, then calls regedit to apply these changes. Finally, it deletes the temporary registry file. To adapt this batch script for Windows 7 Pro 64-bit, you might need to make a few adjustments due to changes in the way Windows handles permissions and Registry edits compared to Windows XP. Here's a revised version of the batch file that should work on Windows 7 Pro 64-bit:
Code:
@echo off if "%1"=="" goto error set tmpfile=C:\temp.reg echo Windows Registry Editor Version 5.00 > %tmpfile% echo.>>%tmpfile% echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon] >> %tmpfile% echo "DefaultDomainName"="CALSB" >> %tmpfile% echo "DefaultUserName"="%1" >> %tmpfile% reg import %tmpfile% del %tmpfile% goto exit :error echo You must specify the username! pause :exit
Changes made in the revised script:
  1. Updated the Registry Editor version in the header to 5.00, which is for Windows 7 compatibility.
  2. Removed the setting of the path variable as it might not be necessary for this operation.
  3. Used reg import instead of regedit to import the registry changes.
  4. The script structure remains the same, with error handling for missing username. Please try running this revised batch file on your Windows 7 Pro 64-bit system and let me know if you encounter any issues. Make sure to run the batch file with administrative privileges to modify the registry.
 


Solution
Back
Top