Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon Script runs correctly -- Mapped drives do not show

Status
Not open for further replies.

creiners

IS-IT--Management
Jun 16, 2004
8
US
I have been running a vblogon script that has been working for several years now. Recently on some of my XP machines, the logon script runs correctly, my log file shows that the drives have mapped, however, when you try to access them they are not showing as mapped.

I am baffled. Any ideas?
 
It would help use all if you would provide the script.
You can edit it to not show any private information.

As a generic response:

. Install Service Pack 2
. begin the logon script with:

net use * /delete
net use /Persistent:No
 
I knew better too... It is quite long but I do alot with my logon scripts. This is a VERY stripped down version but has all of the relevant subs:

Code:
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
'
' NAME: logon.vbs
'
' AUTHOR: Craig Reiners, Mediacom
' Created On : 12.10.2002
' Last Modified: 11.10.2003
'
' COMMENT: 
'
'==========================================================================
On Error Resume Next

Dim WshNetwork, asdPath, User
Dim strMappedDrives, strStatus
Dim IE, UserName
Dim Serv1, Serv2
Dim oDrives, oPrinters


' #################################################################
' ##                                                             ##
' ##					Declare Servers							 ##
' ##															 ##
' #################################################################

Serv1 = "\\server1"
Serv2 = "\\server2"
' #################################################################
' ##															 ##
' ##			Call Subs - DO NOT CHANGE ANYTHING HERE			 ##
' ##															 ##
' #################################################################

Const ADS_READONLY_SERVER = 4

Call CreateIE()' Display IE status window

Set objDomain = getObject("LDAP://rootDse")
objDC = objDomain.Get("dnsHostName")

set fso = CreateObject ("Scripting.FileSystemObject")

If fso.FileExists("c:\logon.log") Then
  set USERDel = fso.GetFile ("C:\logon.log")
  USERDel.Delete
End If 

Set C = fso.CreateTextFile ("c:\logon.log",True)

' #################################################################
' ##                                                             ##
' ##			Creates the HTML Page							 ##
' ##                                                             ##
' #################################################################


strStatus = "Logon Script v2.0.3 " & Date()
strStatus = strStatus & vbCRLF & "Authenticated to: " & objDC

ie.document.all.wstatus.InnerText = strMsg3
IE.Document.all.holdit.checked = False

' Get the User ID

Set WSHNetwork = WScript.CreateObject("WScript.Network")
strUser = ""
While strUser = ""
	strUser = WSHNetwork.UserName
Wend

Domainname = WshNetwork.UserDomain
UserName = WSHNetwork.UserName

Set oDrives = WshNetwork.EnumNetworkDrives
Set oPrinters = WshNetwork.EnumPrinterConnections



Call FullName(DomainName,UserName)

Call UpdateCIC()
Call DivisionAll()

call main()

strStatus = strStatus & vbCRLF & "Network Logon Complete..."
ie.document.all.wstatus.InnerText = strStatus

c.writeline strStatus

' Close IE status window

'IE.Document.all.holdit.checked = True


	WScript.Sleep 2000
	IE.quit()


' End of logon script

' #################################################################
' ##															 ##
' ##			SUB DECLARATIONS								 ##
' ##															 ##
' #################################################################

Public Sub Main()

  'Main loop to detect group that user belongs to
  adsPath = "WinNT://Mycompany/" & strUser
  Set dso = GetObject("WinNT:")
  Set objUser = dso.OpenDSObject(adsPath,"","", ADS_READONLY_SERVER)
 
  For Each Prop In objUser.groups
    Select Case Prop.Name
	
		Case "Group1"
			Call Group1Sub
	
	End Select
  Next 'Prop
  
End Sub

' #### Case Subs Below ####

' #### Everyone ####

Sub DivisionAll()

  strStatus = strStatus & vbCRLF & "Member of North Central Division"
  ie.document.all.wstatus.InnerText = strStatus

  MapDrive "P:", Serv1 & "\public"

End Sub
' #### End Everyone ####

' #### Group1 ####

Sub Group1Sub()

  strStatus = strStatus & vbCRLF & "Connecting Customer Service resources ..."
  IE.Document.all.wstatus.InnerText = strStatus
  
  ConnectPrinter Serv2,"CSSR",1
  
End Sub
' #### End Des Moines CSR ####

' ######################################################
' ####												####
' #### Operations Subs Below -- DO NOT CHANGE THESE ####
' ####												####
' ######################################################

Sub hold()

	IE.Document.All.holdit.checked = True
	WScript.Echo "Checked"

End Sub

' #### Create the IE Window ####
Sub CreateIE()
On Error Resume Next
  Set IE = CreateObject("InternetExplorer.Application")
  With IE
    .navigate "about:blank"
    .resizable=0
    .height=400
    .width=350
    .menubar=0
    .toolbar=0
    .statusBar=0
    .visible=1

	.document.writeln("<HTML>")
	.document.writeln("<head>")
	.document.writeln("<title>MyCompany Network Logon</title>")
	.document.writeln("</head>")
	.Document.writeln("<Script Language=VBScript>")
	.Document.writeln("Sub Hold()")
	.Document.writeln("	  document.all.holdit.checked = true")
	.Document.writeln("End Sub")
	.Document.writeln("</Script>")
	.document.writeln("<body onclick='hold()' SCROLL='no'>")
	.document.writeln("<table border='0' width='313' cellspacing='0' cellpadding='0'>")
	.document.writeln("  <tr>")
	.document.writeln("    <td width='311'><img border='0' src='\\mydomain\SYSVOL\mydomain.com\scripts\home_logo.gif' width='311' height='122'></td>")
	.document.writeln("	</tr>")
	.document.writeln("  <tr>")
    .document.writeln("")
	.document.writeln("  </tr>")
	.document.writeln("  <tr>")
	.document.writeln("    <td><font face='Tahoma'><CENTER>&nbsp;Welcome to the MyCompany domain!</CENTER>")
	.document.writeln("      <marquee ID=scrolling width='95%' height='23'></marquee>")
	.document.writeln("      </font>")
	.document.writeln("      <p><font face='ARIAL'>User Name:&nbsp;</font>")
	.document.writeln("      <font face='Tahoma' ID=Msg1></Font></p>")
	.document.writeln("      <p>&nbsp;<font face='ARIAL'>Mapping Drives:&nbsp;</font>")
	.document.writeln("      <font face='Tahoma' ID=Msg2></Font></p>")
	.document.writeln("      <hr size='4' color=Red>")
	.document.writeln("    </td>")
	.document.writeln("  </tr>")
	.document.writeln("  <tr>")
	.document.writeln("    <td>")
	.document.writeln("    <textarea rows='5' name='wstatus' cols='60' style='font-family: Arial; font-size: 8pt'></textarea></td>")
	.document.writeln("  </tr>")
	.document.writeln("</table>")
	.document.writeln("<input type='checkbox' name='holdit'>")
	.document.writeln("</body>")
	.document.writeln("</html>")

  Do while IE.Busy
     'wait for page to load
    Wscript.Sleep 2000
  Loop

End With

End Sub
' #### Map Drives ####

Sub MapDrive(strDrive,strShare)
		
	On Error Resume Next
	
	For i = 0 to oDrives.Count - 1 Step 2
       
        If oDrives.Item(i+1) = strShare Then
           
           strStatus = strStatus & vbCRLF & strDrive & strShare & " already mapped."
           i = oDrives.count
           		
           		strMappedDrives = strMappedDrives & strDrive & " "
				ie.document.all.Msg2.InnerText = strMappedDrives

           Exit Sub
           
        Else
          
			WSHNetwork.MapNetworkDrive strDrive, strShare

			If Err.Number Then

				Err.Clear
				WSHNetwork.RemoveNetworkDrive strDrive
		
				WScript.Sleep 2000 ' Allow drive to finish unmapping.
		
				WSHNetwork.MapNetworkDrive strDrive, strShare
		
				If Err.Number <> 0 Then 'IF there is still an err then hold IE
					ie.document.all.holdit.checked = True
				Else
					IE.Document.all.holdit.checked = False	
				End If
				
			End If
		End If 
	Next
				strMappedDrives = strMappedDrives & strDrive & " "
				ie.document.all.Msg2.InnerText = strMappedDrives
				strStatus = strStatus & vbCRLF & strDrive & strShare & " " & Err.Description

 '  use to troubleshoot Err.Number
 '  MsgBox(Err.Number)
 '  MsgBox(Err.Description)
	

	
End Sub

' #### Connect Printers ####
                                        
Sub ConnectPrinter(Server, Queue, Default)
	 
	 Queue = "\" & Queue
'	 Server = "\\" & Server
	 PrintPath = Server & Queue 
     MapCount = MapCount + 1
     
     On error resume next

     For i = 0 to oPrinters.Count - 1 Step 2
       
        If oPrinters.Item(i+1) = PrintPath Then
           
           i = oPrinters.Count
           
		     ' Check for Default printer    
		    If Default = 1 Then
		     	WSHNetwork.SetDefaultPrinter(PrintPath)
     			strStatus = strStatus & vbCRLF & PrintPath & " (DEFAULT) Already Mapped."
     		Else
  				strStatus = strStatus & vbCRLF & PrintPath & " Already Mapped."
     		End If 

           Exit Sub 
           
        Else
             
            WsHNetwork.AddWindowsPrinterConnection PrintPath

      		If Err.Number <> 0 Then 'IF there is still an err then hold IE
				ie.document.all.holdit.checked = True
			Else
				IE.Document.all.holdit.checked = False	
			End If
        
        End If
     Next
     
   '  MsgBox (PrintPath)
     
     ' Check for Default printer    
     If Default = 1 Then
     	WSHNetwork.SetDefaultPrinter(PrintPath)
     	strStatus = strStatus & vbCRLF & PrintPath & " (DEFAULT) " & Err.Description
     Else
  		strStatus = strStatus & vbCRLF & PrintPath & " " & Err.Description
     End If 
     
'     Server = NULL
     Queue = NULL
     PrintPath = Null
     
End Sub

' #### Locate and display user's Full Name as set in AD ####

Sub FullName(DomainName,UserName)

	WScript.Sleep(2000)
	
	Set fName = GetObject("WinNT://" & domainname & "/" & UserName & ",user")
	
	ErrNum = Err.Number
	
	On Error GoTo 0               're-enable WSH error checking.
	
	If ErrNum = 0 Then
     	ie.document.all.Msg1.InnerText = fName.FullName
	Else
     	IE.Document.all.Msg1.InnerText = UserName & " (Full name Unavailable)"     	
	End If
	
	c.writeline fName.FullName
	
End Sub
 
Disable fast logon optomization in XP. See the last paragraph of faq779-4017
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top