Windows Server 2008 VBS login script

Hi!

We have a VBS login script but I just want un specific user to map different drive.

Like if the username = "JSMITH" then goto then end of the script and run something else.

is it possible?

Thanks!
service_informatiqueAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan WalkerAdjunct FacultyCommented:
It's very easy in vbscript.  Are you grabbing groups/usernames already?  If so, just make sure objNetwork below is the Network object you've defined to save on redundant code.  

Modifying a script from http://www.computerperformance.co.uk/Logon/Logon_HomeDirAdv.htm

' MNDUserName.vbs
' VBScript to map a network drive to the UserName.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.3 - April 24th 2010
' ----------------------------------------------------' 
Option Explicit
Dim objNetwork 

' Purpose of script to create a network object. (objNetwork)
' Then to apply the MapNetworkDrive method. Result J: drive
Set objNetwork = WScript.CreateObject("WScript.Network") 
' Here is where we extract the UserName
strUserName = objNetwork.UserName 
if (strUsername = "jsmith") then
<jsmith's commands>
else
<rest of login script>
end if

WScript.Quit

' End of MapNetworkDrive Example logon script.

Open in new window


You could also call another vbscript in the jsmith area and then wscript.quit also.
Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")

objShell.Run "TestScript.vbs" 

' Using Set is mandatory
Set objShell = Nothing
Wscript.Quit

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy LidbetterCommented:
I was going to suggest trying this... just add it into the middle of your login script and change the required values in <>

'start script

On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")

'find user name

strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
strUserName = objUser.CN

' if user then map network drive

Select Case strUserName
Case "<USERNAME>"
objNetwork.MapNetworkDrive "<DRIVE LETTER>:", "<NETWORK PATH>"

End Select
Next

'end script

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.