Hide/show the last user in the Windows logon box

After starting Windows the logon dialog box shows the name of the last user who has logged on to the machine. Windows provides a feature to hide this user name. The following script allows you the hide or show the last user's name in the logon dialog box. The dialogs are in English and in German.

//************************************************
// File:   WSHHideUser.js  
// Author: (c) G. Born  
//
// This module enables or disables the "last user login name" 
// display in the Windows 95/98/NT login dialog box.
//
// In no way shall the author be liable for any
// losses or damages resulting from the use of this
// program. Use AS-IS at your own risk.
//
// The code is the property of the author. You may
// use the code and modify it, as far as this header
// remains intact. Further updates and other samples
// may be found on my site:
// http://www.borncity.de
//************************************************
var vbYesNo = 4;                // a few constants for Popup
var vbOK = 0
var vbInformation = 64;
var vbCancel = 2;
var vbYes = 6
// set the variable for the Registry key
var Root = "HKEY_LOCAL_MACHINE";
var key = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Winlogon\\";
var valname = "DontDisplayLastUserName";    // value name
var result;
// we need the Shell object for Registry operation
var WSHShell = WScript.CreateObject("WScript.Shell");
{
 result = WSHShell.Popup(
    "Letzer Benutzer im Windows-Anmeldedialog ausblenden?\n\n\r" +
     "Hide last user's name in login dialog box",
    0,
    "Windows 98 - powered by Günter Born",
    vbYesNo + vbInformation );
    if (result == vbYes) 
     {
      WSHShell.RegWrite(Root + key + valname, "1", "REG_SZ");
      WSHShell.Popup("Anzeige Benutzername ausgeschaltet"+
                     "\n\n\rHide last user's login name",
                      0,
      "http://www.borncity.de",
                      vbOK);
     } 
     else
     {
      WSHShell.RegWrite(Root + key + valname, "1", "REG_SZ");
      WSHShell.RegDelete(Root + key + valname);
      WSHShell.Popup("Anzeige Benutzername zugelassen" +
                     "\n\n\rShow last user's login name", 
                      0,
      "http://www.borncity.de",
                      vbOK); 
     }
}
//*** End

The script writes into the Registry. The key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Winlogon

may contain the value DontDisplayLastUserName which may be set either to 0 or to 1. The value shows or hides the user name during logon. To use this script under Windows NT it needs the administrator rights (or the rights to modify the keys). Details about these Registry keys may be found in my title "Inside the Registry of Microsoft Windows 98" (Microsoft Press).

Back

(c) G. Born