[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

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

0
ipcipher
Asked:
ipcipher
1 Solution
 
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now