Solved

script to map drives

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
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…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

808 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