VB scripting question

Status
Not open for further replies.

OldManBrodie

Ars Legatus Legionis
44,321
Subscriptor
at work, i made up a vbs file that serves as our login script. it basically just maps various network drives. some are defaulot for everybody, and others are decided by simple if/then statements based on username.

the problem is, on the new xp boxes that we have (5 or 6 of them), upon login, the server shows every xp user just sitting in the shared network drives, regardless of whether or not they are in them on their computer.

is this a VBS issue with xp? if so, how would i go about fixing it?

it seems as if the script is opening up the directory when it maps the drives, but isn't closing them.

the issue cannot be repeated on the windows 98 or 95 pc's. and once we close the shares that are sitting there open, they stay closed until you re-login.
 

OldManBrodie

Ars Legatus Legionis
44,321
Subscriptor
Originally posted by Jackass JoeJoe:
Did you disable Fast User switching?
yes

here's the script:

code:<HR>
Code:
dim mynetobj
set mynetobj = wscript.createobject("Wscript.network")<P>'--------------------------------------------------------------
'Tells the script to resume even if there's an error
'--------------------------------------------------------------
on error resume next<P>'--------------------------------------------------------------
'This command puts the username into all lowercase, and stores
' it to the variable "User"
'--------------------------------------------------------------
User = LCase(mynetobj.username)<P>'--------------------------------------------------------------
'These commands disconnect all network drives
'--------------------------------------------------------------
mynetobj.removenetworkdrive "E:", true, true
mynetobj.removenetworkdrive "F:", true, true
mynetobj.removenetworkdrive "G:", true, true
mynetobj.removenetworkdrive "H:", true, true
mynetobj.removenetworkdrive "L:", true, true
mynetobj.removenetworkdrive "M:", true, true
mynetobj.removenetworkdrive "P:", true, true
mynetobj.removenetworkdrive "O:", true, true
mynetobj.removenetworkdrive "Q:", true, true
mynetobj.removenetworkdrive "S:", true, true
mynetobj.removenetworkdrive "T:", true, true
mynetobj.removenetworkdrive "U:", true, true
mynetobj.removenetworkdrive "W:", true, true
mynetobj.removenetworkdrive "Y:", true, true
mynetobj.removenetworkdrive "Z:", true, true<P>'---------------------------------------------------------------
'These commands start mapping the network drives
'---------------------------------------------------------------
mynetobj.mapnetworkdrive "F:", "\\thatcher\sysvol"
mynetobj.mapnetworkdrive "G:", "\\thatcher\apps"
If StrComp (mynetobj.username, "njtodd") = 0 Then
mynetobj.mapnetworkdrive "H:", "\\thatcher\dcmccart"
else
mynetobj.mapnetworkdrive "H:", "\\thatcher\" & User
End If<P>'---------------------------------------------------------------
'This section checks to see if a user who is not part of
' tech group needs a network drive for \\Thatcher\Techgrp and
' maps the drive if they do
' Syntax for StrComp (string compare):
'  StrComp (string1, string2)
'  This will return a value of -1, 0, or 1
'  -1 and 1 = the two strings are not equal
'  0 = the two strings are equal
'---------------------------------------------------------------
If StrComp (User, "dcmccart") = 0 Then
mynetobj.mapnetworkdrive "K:", "\\Thatcher\Techgrp"
ElseIf StrComp (User, "dlekstrom") = 0 Then
mynetobj.mapnetworkdrive "Y:", "\\Thatcher\Techgrp"
ElseIf StrComp (User, "tmfila") = 0 Then
mynetobj.mapnetworkdrive "K:", "\\Thatcher\Techgrp"
End If<P>'---------------------------------------------------------------
'This section checks to see if a user is part of tech group 
' and if so, maps a network drive (L:) for \\Thatcher\Techgrp
'---------------------------------------------------------------
If StrComp (User, "amspang") = 0 Then
mynetobj.mapnetworkdrive "L:", "\\Thatcher\Techgrp"
ElseIf StrComp (User, "dkwohlfo") = 0 Then
mynetobj.mapnetworkdrive "L:", "\\Thatcher\Techgrp"
ElseIf StrComp (User, "lwhitman") = 0 Then
mynetobj.mapnetworkdrive "L:", "\\Thatcher\Techgrp"
ElseIf StrComp (User, "rtlynn") = 0 Then
mynetobj.mapnetworkdrive "L:", "\\Thatcher\Techgrp"
ElseIf StrComp (User, "dlstrebe") = 0 Then
mynetobj.mapnetworkdrive "L:", "\\Thatcher\Techgrp"
ElseIf StrComp (User, "fmekstro") = 0 Then
mynetobj.mapnetworkdrive "R:", "\\Thatcher\Techgrp"
ElseIf StrComp (User, "tafrazie") = 0 Then
mynetobj.mapnetworkdrive "L:", "\\Thatcher\Techgrp"
ElseIf StrComp (User, "tefarkas") = 0 Then
mynetobj.mapnetworkdrive "L:", "\\Thatcher\Techgrp"
ElseIf StrComp (User, "jgungles") = 0 Then
mynetobj.mapnetworkdrive "L:", "\\Thatcher\Accting"
mynetobj.mapnetworkdrive "K:", "\\Thatcher\Departments"
Else
mynetobj.mapnetworkdrive "L:", "\\Thatcher\Departments"
End If<P>'--------------------------------------------------------------
'This continues to map the rest of the network drives
'--------------------------------------------------------------
mynetobj.mapnetworkdrive "M:", "\\thatcher\apps"
mynetobj.mapnetworkdrive "P:", "\\thatcher\training"
mynetobj.mapnetworkdrive "O:", "\\thatcher\schedule"<P>'--------------------------------------------------------------
'This maps sys on \\pkgwshr for Sue
'--------------------------------------------------------------
If StrComp (User, "sgpankow") = 0 Then
mynetobj.mapnetworkdrive "Q:", "\\pkgwshr\sys"
End If<P>
'--------------------------------------------------------------
'This continues to map the rest of the network drives
'--------------------------------------------------------------
mynetobj.mapnetworkdrive "S:", "\\thatcher\share"
mynetobj.mapnetworkdrive "U:", "\\thatcher\users"
mynetobj.mapnetworkdrive "T:", "\\thatcher\template"
mynetobj.mapnetworkdrive "W:", "\\thatcher\apps"<P>
'---------------
'---------------<P>If StrComp (User, "dleckstrom") = 0 Then
mynetobj.mapnetworkdrive "Z:", "\\Thatcher\Quality"
End If
 
Status
Not open for further replies.