Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for cllun.bat

(view source code of cllun.bat as plain text)

  1. @ECHO OFF
  2. ECHO.
  3. ECHO CLLUN.bat,  Version 1.00 for Windows 9x and 2000
  4. ECHO Clear or modify Last Logon User Name
  5. ECHO.
  6. ECHO Usage:   CLLUN  [ new logon user name ]
  7. ECHO.
  8. ECHO Invoking CLLUN without parameters will clear the
  9. ECHO last logon user name from the logon dialog.
  10. ECHO If an optional command line parameter is specified,
  11. ECHO the last logon user name will be set to that value.
  12. ECHO.
  13. ECHO Written by Rob van der Woude
  14. ECHO http://www.robvanderwoude.com
  15. ECHO.
  16.  
  17. :: Command line parameters check
  18. ECHO.%1 | FIND "?" > NUL
  19. IF NOT ERRORLEVEL 1 GOTO Error
  20. IF NOT [%2]==[] GOTO End
  21.  
  22. :: Display a warning
  23. SET _modify_=clear
  24. IF NOT [%1]==[] SET _modify_=modify
  25. ECHO You are about to %_modify_% the last user logon name in the registry.
  26. SET _modify_=
  27. ECHO Press Ctrl+C to abort or any other key to continue . . .
  28. PAUSE > NUL
  29.  
  30. :: Create temporary REG file
  31. >  "%TEMP%.\LogonName.reg" ECHO REGEDIT4
  32. >> "%TEMP%.\LogonName.reg" ECHO.
  33.  
  34. :: Windows version check
  35. VER | FIND "Windows 2000" >NUL
  36. IF NOT ERRORLEVEL 1 GOTO Win2K
  37. VER | FIND "Windows 9" >NUL
  38. IF NOT ERRORLEVEL 1 GOTO Win9x
  39. GOTO Error
  40.  
  41. :Win9x
  42. >> "%TEMP%.\LogonName.reg" ECHO [HKEY_LOCAL_MACHINE\Network\Logon]
  43. >> "%TEMP%.\LogonName.reg" ECHO "UserName"="%1"
  44. GOTO Merge
  45.  
  46. :Win2K
  47. >> "%TEMP%.\LogonName.reg" ECHO [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
  48. >> "%TEMP%.\LogonName.reg" ECHO "Logon User Name"="%1"
  49. >> "%TEMP%.\LogonName.reg" ECHO.
  50. >> "%TEMP%.\LogonName.reg" ECHO [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
  51. >> "%TEMP%.\LogonName.reg" ECHO "AltDefaultUserName"="%1"
  52. >> "%TEMP%.\LogonName.reg" ECHO "DefaultUserName"="%1"
  53.  
  54. :Merge
  55. >> "%TEMP%.\LogonName.reg" ECHO.
  56. :: Use REG file to change registry setting
  57. START /WAIT REGEDIT.EXE /S "%TEMP%.\LogonName.reg"
  58. :: Remove temporary file
  59. DEL "%TEMP%.\LogonName.reg"
  60. GOTO End
  61.  
  62. :Error
  63. ECHO.
  64. ECHO Error: wrong Windows version.
  65. ECHO This script is intended for Windows 9x and 2000 only.
  66. ECHO.
  67. PAUSE
  68.  
  69. :End
  70. CLS
  71.  

page last modified: 2024-04-16; loaded in 0.0083 seconds