[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

script to map drives

Posted on 2014-03-17
2
Medium Priority
?
421 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

649 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