Solved

script to map drives

Posted on 2014-03-17
2
402 Views
Last Modified: 2014-03-28
I want to add another mapped drive under "objNetwork.MapNetworkDrive "P:", "\\printserver\printers""

Can someone assist on what I would need to put next to add a Q drive that maps to "\\Printers_Win7"?

Script I have below that someone created in our environment. Its a logon script I want to add to. Thanks





'==========================================================================

Dim strDomainName, strUser, objNetwork, WinNTPath, objWinNT            ' Setting Enviroment variables
Set objNetwork = WScript.CreateObject("WScript.Network")                ' Creating network object
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
strDomainName = objNetwork.UserDomain                                   ' Assign domain
Domain to variable
strUserName = objNetwork.UserName                                       ' Assign username to variable

WinNTPath="WinNT://" & strDomainName & "/" & strUserName                ' Binding to user object in WinNT
Set objWinNT=GetObject(WinNTPath)                                        

If fso.DriveExists("S:") then
    objNetwork.RemoveNetworkDrive "S:", True, True
End if
objNetwork.MapNetworkDrive "S:", "\\server\adroc_share\U01\Share"

If fso.DriveExists("P:") then
    objNetwork.RemoveNetworkDrive "P:", True, True
End if
objNetwork.MapNetworkDrive "P:", "\\printserver\printers"
0
Comment
Question by:Thomas N
[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 Comments
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39935002
just add below line at the end of script

If fso.DriveExists("Q:") then
    objNetwork.RemoveNetworkDrive "Q:", True, True
End if
objNetwork.MapNetworkDrive "Q:", "\\Printers_Win7" 

Open in new window

0
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 500 total points
ID: 39935421
Your 'printers' share is probably not correct, you say it should map to:
"\\Printers_Win7"

But that is just a 'server' name, you are missing a 'share' name.

Do you know the share name? If you do, map to:
"\\Printers_Win7\<share name>" (replacing <share name> with the real name)

If  you don't know the share name, try finding it like this:

net view \\Printers_Win7

This should display a list of available shares from 'server' Printers_Win7 - find the correct share name and use that to map your Q drive.
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Issue: One Windows 2008 R2 64bit server on the network unable to connect to a buffalo Device (Linkstation) with firmware version 1.56. There are a total of four servers on the network this being one of them. Troubleshooting Steps: Connect via h…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to count occurrences of each item in an array.

691 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