Solved

Mapping drives based on computer name?

Posted on 2004-09-13
4
318 Views
Last Modified: 2008-01-09
Is this possible? I would like to use Group Policy and VB

We already have a VB logon script that maps drives. The problem is that there are 3 computers that need Drive P mapped to a different server. There are MACHINES that need to different, no USERS.

Thanks,

Jim
0
Comment
Question by:jimgaudet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 57

Accepted Solution

by:
Pete Long earned 125 total points
ID: 12046254
I dont know VB from beans!

cant you echo %computername% then If computername = xyz then map the drive?
0
 
LVL 15

Expert Comment

by:adamdrayer
ID: 12046929
Yep.  you can.  Like Pete says, just access the environment variable %computername% and make it a conditional.
0
 
LVL 1

Author Comment

by:jimgaudet
ID: 12047557
Can anyone type the script for me?

Here is what I have done; It doesn't seem to remove the Old Mapped P: drive until I manually disconnec it, then it will work properly

' Visiting Nurses Association and Hospice of Vermont and New Hampshire
' Logon Script created on 08-11-2004 by Jim Gaudet


Option Explicit
Dim objNetwork, net, fso, WshNetwork, computer, wshComputer, cpu01wsh, cpu02wsh, cpu03wsh, cpu04wsh

Set objNetwork = CreateObject("WScript.Network")
' Forces script to skip errors (rem below line to see errors)
on error resume next

Set WshNetwork = CreateObject("WScript.Network")
' Remove Network Drives
WshNetwork.RemoveNetworkDrive "g:"
WshNetwork.RemoveNetworkDrive "k:"
WshNetwork.RemoveNetworkDrive "p:"
WshNetwork.RemoveNetworkDrive "s:"
WshNetwork.RemoveNetworkDrive "y:"

' Map Network Drives
objNetwork.MapNetworkDrive "g:", "\\wrj-file\groups$"
objNetwork.MapNetworkDrive "k:", "\\vnavnh.org\common"
objNetwork.MapNetworkDrive "p:", "\\vnaapps\mckesson"
objNetwork.MapNetworkDrive "s:", "\\wrj-file\software"
objNetwork.MapNetworkDrive "y:", "\\wrj-apgl\program files"

' SETTING THE PRINTERS
Set net = CreateObject("WScript.Network")
'net.AddWindowsPrinterConnection "\\wrj-file\wrj-it", "IT Printer"
'net.AddWindowsPrinterConnection "\\wrj-file\yellow", "Yellow"
'net.AddWindowsPrinterConnection "\\wrj-file\training", "Training"
'net.AddWindowsPrinterConnection "\\wrj-file\randolph", "Randolph"
'net.AddWindowsPrinterConnection "\\wrj-file\oldbills", "Old Bills"
'net.AddWindowsPrinterConnection "\\wrj-file\mck-finance", "Mck-Finance"
'net.AddWindowsPrinterConnection "\\wrj-file\FinancePCL", "Finance PCL"
'net.SetDefaultPrinter "\\wrj-file\wrj-it"

'Copy Paging Link
set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile "\\Wrj-file\Common\pagers\paging.lnk", "c:\documents and settings\all users\desktop\Paging.lnk"
set fso = nothing

Set wshComputer = createobject("wscript.network")
computer = wshComputer.computername


if computer = "DBMSTEST" then
set cpu01wsh = createobject("wscript.network")
cpu01wsh.RemoveNetworkDrive "p:"
cpu01wsh.MapNetworkDrive "p:", "\\appstest\mckesson"
End If

if computer = "APPSTEST" then
set cpu02wsh = createobject("wscript.network")
cpu02wsh.RemoveNetworkDrive "p:"
cpu02wsh.MapNetworkDrive "p:", "\\appstest\mckesson"
End If

if computer = "VNA-001909" then
set cpu03wsh = createobject("wscript.network")
cpu03wsh.RemoveNetworkDrive "p:"
cpu03wsh.MapNetworkDrive "p:", "\\appstest\mckesson"
End If

if computer = "VNA-001428" then
set cpu04wsh = createobject("wscript.network")
cpu04wsh.RemoveNetworkDrive "p:"
cpu04wsh.MapNetworkDrive "p:", "\\appstest\mckesson"
End If
0
 
LVL 1

Author Comment

by:jimgaudet
ID: 12126252
HELP. this just doesn't delete the old drive first
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FIPS stands for the Federal Information Processing Standardisation and FIPS 140-2 is a collection of standards that are generically associated with hardware and software cryptography. In most cases, people can refer to this as the method of encrypti…
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question