Figure 1   Simple Logon Script


<job>
<script language="vbscript">
on error resume next

set wshNetwork = WScript.CreateObject( "WScript.Network" )
Set wshShell = WScript.CreateObject("WScript.Shell" )

do while wshNetwork.username = ""
WScript.Sleep 250
loop

user = wshNetwork.username
domain = wshNetwork.userdomain

Wscript.echo "Logging on " & ucase(domain) & "\" & user & "..."

' use ADSI get list of groups the user belongs to
adspath = "WinNT://" & domain & "/" & user
set adsobj = getobject( adspath )

' call a different subroutine based on the Windows NT group of the user
' for each prop in adsobj.groups
    select case prop.name
        case "Administrators"
            call Adminslogon

        case "chicago"
            call Chicagologon

    end select
next
</script>
</job>

Figure 2   checkNetworkMapping


' see if a network mapping is present, if not add it
Function CheckNetworkMapping(DriveLetter)
    Dim Drive
    WScript.Echo "Looking for network mapping on drive " & DriveLetter
    CheckNetworkMapping = False
    For Each Drive In wshNetwork.enumNetworkDrives
        If LCase(Drive) = LCase(DriveLetter) Then
            CheckNetworkMapping = True
            Exit For
        End If
    Next
    If CheckNetworkMapping Then
        WScript.Echo "Network Mapping Found"
    Else
        WScript.Echo "Network Mapping Not Found"
    End If
End Function

' this subroutine is called to map a network share directory to a drive letter
sub mapNetwork(driveletter, netshare)
    on error resume next
    err.clear

    WScript.Echo "Adding Network Mapping."
    wshNetwork.MapNetworkDrive driveletter, netshare, true

    if err <> 0 then
        'the Mapping failed - execute recovery routine
        WScript.Echo "unable to map" & driveletter & " to " & netshare
    else
        WScript.Echo "Finished."
    end if
end sub

Figure 3   GetIPAddress and GetRAM

function GetIPAddress (server, username, password)
    set objLocator = WScript.CreateObject("WbemScripting.SWbemLocator")
    set objService = objLocator.ConnectServer (server, "", username, password)
    strQuery = "Select IPAddress from _
        Win32_NetworkAdapterConfiguration where IPEnabled=TRUE"

    set objEnumerator = objService.ExecQuery(strQuery)

    for each obj in objEnumerator
        if Not IsNull(obj.IPAddress) then 
            for i=LBound(obj.IPAddress) to UBound(obj.IPAddress)
                GetIPaddress = obj.IPAddress(i)
            next
        end if
    next
end function

function GetRAM (server, username, password)
    set objLocator = WScript.CreateObject("WbemScripting.SWbemLocator")
    set objService = objLocator.ConnectServer (server, username, password)
    strQuery = "Select TotalPhysicalMemory From Win32_LogicalMemoryConfiguration"

    set objEnumerator = objService.ExecQuery(strQuery)

    for each obj in objEnumerator
        GetRam = obj.totalPhysicalMemory
    next
end function

Figure 4   Configuring Users


sub CreateUser(ServerName, name, password, fullname, logonscript)
    on error resume next
    err.clear

    set objServer = GetObject("WinNT://" & ServerName)
    set objUser = objServer.Create ("user", name)
    objUser.Fullname = fullname
    objUser.setPassword password
    objUser.loginscript = logonscript
    objUser.SetInfo

    if err <> 0 then 
        WScript.Echo "Unable to create user" & name
    Else
        Wscript.Echo "Finished creating user: " & name
    end if
end sub

CreateUser "vernonh0", "KenT", "abc123", "Kenneth Tam", "logon.wsf"
CreateUser "vernonh0", "MariaL", "abc123", "Maria Lau", "logon.wsf"
CreateUser "vernonh0", "VinceH", "abc123", "Vince Hui", "logon.wsf"