Solved

Mapping drives based on computer name?

Posted on 2004-09-13
4
316 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
  • 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Greetings, Experts! First let me state that this website is top notch. I thoroughly enjoy the community that is shared here; those seeking help and those willing to sacrifice their time to help. It is fantastic. I am writing this article at th…
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 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