Cannot Retrieve UserName Property in Windows Script Host

ID: Q233976


The information in this article applies to:
  • Microsoft Windows 95
  • Microsoft Windows 98


SYMPTOMS

When you try to retrieve the UserName property using the WScript.Network object in a Windows 95/98 logon script, you receive a null value.


CAUSE

This issue occurs because a Windows 95/98 logon script is run before the logon process is complete.


RESOLUTION

To work around this issue, use a While loop to continue to retrieve the value as long as it remains null.

The following VBScript code is a sample of how to implement the workaround.


Dim strUserName
Set WSHNetwork = CreateObject("WScript.Network")
While strUserName = ""
    strUserName = WSHNetwork.UserName
WEnd 

Additional query words:

Keywords : kbenv kbprg kbtool
Version : WINDOWS:95
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: June 2, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.