Rem: Using WSH Logon Scripts for Win9x

If you’re having problems running WSH logon scripts on Win9x clients, your scripts might not be causing the problems but rather a quirk in the Win9x system. Learn about this quirk and how to work around it.

Bob Wells

June 24, 2001

1 Min Read
ITPro Today logo in a gray background | ITPro Today


I created a .vbs logon script for a mixed environment of Windows 2000, Windows NT 4.0, and Windows 98 machines running Microsoft Active Directory Service Interfaces (ADSI) 2.5 and Windows Script Host (WSH) 2.0. The script works on the Win2K and NT 4.0 clients but not the Win98 clients. Do you know what's wrong?

Determining the exact problem is difficult without seeing the logon script and the error message that appears on your Win98 clients. However, you might be experiencing a problem that commonly occurs when you use WSH on Win9x clients. WSH-based logon scripts often use the WshNetwork object's UserName property to retrieve the name of the currently logged-on user. However, Win9x logon scripts start before the user is fully logged on to the domain. As a result, the UserName property value isn't available when the logon script begins executing.

To work around this problem, the logon script needs to continuously check for the value of the UserName property until that value becomes available, at which point the logon script can continue. One way to continuously check for this value is to use VBScript's Do...Loop statement. As the code in Listing 6 shows, you begin by initializing the strUsername variable to an empty string. Next, you test the value of strUsername. If strUsername is empty, you initialize the string with the value of the Network object's Username property. The loop continues until the Username property value becomes available, thereby initializing strUsername, which causes the loop to exit.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like