How can i change this vbscript so that it maps the network drive based on the computer name?

How can i change this vbscript so that it maps the network drive based on the computer name?


Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "F:", "\\acsms01\Data\ds4"
objNetwork.MapNetworkDrive "w:", "\\acsms02\users\" & objnetwork.UserName

Open in new window

LVL 1
ipcipherAsked:
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.

mass2612Commented:
Hi,

I have not seen this done based on the computer name but you might be best to consider mapping based on the groups that the user is a member of?

Take a look at this script - http://www.pcreview.co.uk/forums/thread-1530889.php
0
Shift-3Commented:
Just change objnetwork.UserName to objnetwork.ComputerName.

0
RobSampsonCommented:
Hi, I'm not sure why you would want to map a drive based on the computer name, but it could be done:

Set objNetwork = CreateObject("WScript.Network")
If UCase(objNetwork.ComputerName) = "PCNAME" Then
   objNetwork.MapNetworkDrive "F:", "\\acsms01\Tools\Software"
Else
   objNetwork.MapNetworkDrive "F:", "\\acsms01\Data\ds4"
End If

Or, to check the first two characters, for example:

Set objNetwork = CreateObject("WScript.Network")
Select Case UCase(Left(objNetwork.ComputerName, 2))
   Case "DT"
      objNetwork.MapNetworkDrive "F:", "\\acsms01\Desktops"
   Case "LT"
      objNetwork.MapNetworkDrive "F:", "\\acsms01\Laptops"
   Case "SV"
      objNetwork.MapNetworkDrive "F:", "\\acsms01\Servers"
End Select


Regards,

Rob.
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
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 2003

From novice to tech pro — start learning today.