Cannot Retrieve UserName Property in Windows Script Host (233976)



The information in this article applies to:

  • Microsoft Windows 95
  • Microsoft Windows 98

This article was previously published under Q233976

SYMPTOMS

When you try to retrieve the UserName property by using the WScript.Network object in a Windows 95/98 logon script, you receive a null value. In some cases you may also receive an error code of 800704DD.

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.

On Error Resume Next
Dim strUserName
Set WSHNetwork = CreateObject("WScript.Network")
While strUserName = ""
WScript.Sleep 10 
    strUserName = WSHNetwork.UserName
WEnd
				

Modification Type:MinorLast Reviewed:12/20/2004
Keywords:kbenv kbprb kbProgramming KB233976