WSH Script in NT Logon Script 
Author Message
 WSH Script in NT Logon Script

I have the following script which works fine if I run it after I have logged on. However if I call it from the logon script "suclog.bat" using

start mapt.vbs

I get an error at line 11 saying that the command was not completed because the user is not logged on to the network (or words to that effect). How can I make this work from a logon script. By the way the T drive is not the users home directory, so I cannot just use net use /home. Thanks in advance,

Here is the script

' Windows Script Host
' Script to map users T drive

Dim WSHNetwork
Dim UserName
Dim CRLF

CRLF = Chr(13) & Chr(10)
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Username  = WSHNetwork.UserName
TryMapDrive "T", "\\SAMANEA\"& Username & "t$"

Function TryMapDrive(cDrive, strShare)
    Dim strDrive
    strDrive = cDrive & ":"
    On Error Resume Next
    WSHNetwork.MapNetworkDrive strDrive, strShare
    TryMapDrive = Err.Number = 0
End Function



Mon, 26 Feb 2001 03:00:00 GMT  
 WSH Script in NT Logon Script

Known problem... try this

On Error resume Next
strUser=""
While strUser = ""
  strUser = WSHNetwork.UserName
Wend

You should also put an On Error resume Next in the first line of your function.
Regards,
Ian Morrish
http://wsh.glazier.co.nz WSHFAQ
http://ils.glazier.co.nz (NetMeeting)
http://www.glazier.co.nz


    I have the following script which works fine if I run it after I have logged on. However if I call it from the logon script "suclog.bat" using

    start mapt.vbs

    I get an error at line 11 saying that the command was not completed because the user is not logged on to the network (or words to that effect). How can I make this work from a logon script. By the way the T drive is not the users home directory, so I cannot just use net use /home. Thanks in advance,

    Here is the script

    ' Windows Script Host
    ' Script to map users T drive

    Dim WSHNetwork
    Dim UserName
    Dim CRLF

    CRLF = Chr(13) & Chr(10)
    Set WSHNetwork = WScript.CreateObject("WScript.Network")
    Username  = WSHNetwork.UserName
    TryMapDrive "T", "\\SAMANEA\"& Username & "t$"

    Function TryMapDrive(cDrive, strShare)
        Dim strDrive
        strDrive = cDrive & ":"
        On Error Resume Next
        WSHNetwork.MapNetworkDrive strDrive, strShare
        TryMapDrive = Err.Number = 0
    End Function



Tue, 27 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Run WSH logon script before NT shell starts?

2. Nt Domain Logon Script using VBScript/WSH

3. deploying WSH 5.6 with NT logon script

4. NT Logon Script using WSH / VBScript

5. NT Logon Scripting using WSH

6. WSH NT Logon Scripting

7. How can I get logon server name and IP address from logon script using wsh

8. logon.exe script.vbs in profile (logon script)

9. Logon Scripts in VB for NT logons

10. Logon Script and NT

11. How do I run a .vbs file a NT logon script

12. Logon Scripts in Windows NT

 

 
Powered by phpBB® Forum Software