Solved

Mapping drives based on computer name?

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Configure File History in Windows 10 Pro 13 99
2 LAN/WAN on One Server 2 60
Domain Share problems 5 54
Communication with an active RFID 7 66
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…
The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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