Solved

Mapping drives based on computer name?

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A brief overview to explain gateways, default gateways and static routes OR NO - you CANNOT have two default gateways on the same server, PC or other Windows-based network device. In simple terms a gateway is formed when a computer such as a serv…
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now