Solved

Mapping drives based on computer name?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many of us in IT utilize a combination of roaming profiles and folder redirection to ensure user information carries over from one workstation to another; in my environment, it was to enable virtualization without needing a separate desktop for each…
Trying to figure out group policy inheritance and which settings apply where can be a chore.  Here's a very simple summary I've written which might help.  Keep in mind, this is just a high-level conceptual overview where I try to avoid getting bogge…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

14 Experts available now in Live!

Get 1:1 Help Now