Solved

script to map drives

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This article will show, step by step, how to integrate R code into a R Sweave document
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…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

813 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

11 Experts available now in Live!

Get 1:1 Help Now