Solved

script to map drives

Posted on 2014-03-17
2
389 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
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 37

Accepted Solution

by:
Gerwin Jansen 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

Integrate social media with email signatures

Is your company active on social media? Do you also use email signatures? Including social media icons in your email signature is a great way to get fans for free. Let all your email users know you’re on social media quickly and easily, in a single click.

Join & Write a Comment

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

762 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

19 Experts available now in Live!

Get 1:1 Help Now