Link to home
Start Free TrialLog in
Avatar of vinden
vinden

asked on

Select Case Userstring in login script not working

Hi,

I'm trying to map some specific drives to specific users in a vbs login script.
The setup is fairly simple but for some reason the drives are mapped for every user.

strUser = WSHNetwork.UserName
Select Case strUser
    Case "User1" Or "User2"
         WSHNetwork.MapNetworkDrive "F:", "\\SERVER\DRIVE",True
         WSHNetwork.MapNetworkDrive "Y:", "\\SERVER\DRIVE2",True
         WScript.Echo strUser
End Select

Even if I execute the script as "User3" or "UserSomethingCompletelyDifferent" it still maps the drives. That's why I added an echo at the end. The echo clearly shows a different username than the usernames in the Case expression. But still the drives are mapped.
I don't get it.

ASKER CERTIFIED SOLUTION
Avatar of Bardobrave
Bardobrave
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Brendan M
Brendan M
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vinden
vinden

ASKER

That's it !
I tried Case "User1","User2" and it finally works.
It seems so logical when I used "or"...Guess not.

Thanks !

Avatar of vinden

ASKER

Thanks both of you. Bardo was first.
Hello vinden,

Glad to see you got the help you needed.

Just also be aware that by default VBScript uses case sensitive text comparisons.  Thus, if the user name is
not case sensitive, you should force it to all lower or all upper case before the comparison in the Select Case.

OTOH, if the user name *is* case sensitive, you are golden :)

Regards,

Patrick
Avatar of vinden

ASKER

Thanks Patrick, I will implement that cause userstring is not case sensitive.
For anyone else interested, it's something like this if I'm not mistaken :
Select Case UCase(strUser)