Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Microsoft Support > Windows NT/2000/2003 Server/2008 Server
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Windows NT/2000/2003 Server/2008 Server Find support for Windows NT/2000/2003 Server/2008 Server editions.

Reply
 
LinkBack Thread Tools
Old 02-22-2007, 02:12 PM   #1 (permalink)
Member, Networking Team
 
Join Date: Jan 2005
Location: Ohio
Posts: 1,040
OS: Windows Server 2003


VBS Login Script Map Network Drive

I am trying to convert some of our scripts over to vbs

The network drives are currently being mapped via batch scripts. All of the network drives are already mapped on most workstations. When the following script runs an error message pops up saying "device name already in use". Is there any way to make the script override any existing map and just re-map everytime executed?

If a user has an old network drive using a drive letter we want mapped to another share, I want the script to override that. This is what I have so far, can some one direct me in the right direction? Thanks.

Quote:
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "S:", "\\nw-w2k3-dc-01\Shared"

Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "J:", "\\nw-w2k3-dc-01\APPS"
__________________
Because you can read this thank a teacher, because it's English thank a soldier.
newhouse1390 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 02-22-2007, 04:19 PM   #2 (permalink)
Registered User
 
Join Date: Jun 2006
Location: Mid-West
Posts: 111
OS: WinXP Pro


This should do it.

Quote:
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "S:", "\\nw-w2k3-dc-01\Shared"

On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "J:", "\\nw-w2k3-dc-01\APPS"
I apologize I did not read through everything on your post....

This will not overwrite existing maps it will just allow the error that is generated if a drive letter is already taken to be skipped.

I would like at the following place:

http://www.microsoft.com/technet/scr...a/hsgarch.mspx

Last edited by levi.rogers; 02-22-2007 at 04:21 PM. Reason: Mistake...
levi.rogers is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 02-22-2007, 07:46 PM   #3 (permalink)
Member, Networking Team
 
Join Date: Jan 2005
Location: Ohio
Posts: 1,040
OS: Windows Server 2003


Quote:
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "S:", "\\nw-w2k3-dc-01\Shared"

On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "J:", "\\nw-w2k3-dc-01\APPS"

On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "S:", "\\nw-w2k3-dc-01\Pictures"

On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "J:", "\\nw-w2k3-dc-01\users\%username%"
In therory the above should work but for some reason it only maps the first two drives and not the last two. Any ideas?

Thanks!
__________________
Because you can read this thank a teacher, because it's English thank a soldier.
newhouse1390 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 02-22-2007, 09:04 PM   #4 (permalink)
Member, Networking Team
 
Join Date: Jan 2005
Location: Ohio
Posts: 1,040
OS: Windows Server 2003


Update:

Quote:
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "U:" , "\\nw-w2k3-dc-01\users\%username%"
Report is access denied. Anything wrong with the syntax? Other than that I have got the other three drives to map correctly!
__________________
Because you can read this thank a teacher, because it's English thank a soldier.
newhouse1390 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 02-22-2007, 09:18 PM   #5 (permalink)
Member, Networking Team
 
Join Date: Jan 2005
Location: Ohio
Posts: 1,040
OS: Windows Server 2003


It has to be something with the %username%. I am guessing vbs is a little different. Any oneknow how to correctly fill out that line?

Thanks again.
__________________
Because you can read this thank a teacher, because it's English thank a soldier.
newhouse1390 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 02-23-2007, 09:20 AM   #6 (permalink)
Registered User
 
Join Date: Jun 2006
Location: Mid-West
Posts: 111
OS: WinXP Pro


??

Is that a redirected folder?
levi.rogers is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 02-23-2007, 09:41 AM   #7 (permalink)
Registered User
 
Join Date: Jun 2006
Location: Mid-West
Posts: 111
OS: WinXP Pro


This is how I think it works...

Code:
' MNDUserName.vbs
' VBScript to map a network drive to the UserName.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.3 - April 24th 2005
' -----------------------------------------------------------------'
Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath, strUserName
strDriveLetter = "J:"
strRemotePath = "\\grand\home"

' Purpose of script to create a network object. (objNetwork)
' Then to apply the MapNetworkDrive method. Result J: drive
Set objNetwork = WScript.CreateObject("WScript.Network")
' Here is where we extract the UserName
strUserName = objNetwork.UserName
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath _
& "\" & strUserName

' Extra code just to add a message box
WScript.Echo " Launch Explorer, check: "& strDriveLetter
WScript.Quit

' End of MapNetworkDrive Example logon script.
levi.rogers is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 02-23-2007, 11:43 AM   #8 (permalink)
Member, Networking Team
 
Join Date: Jan 2005
Location: Ohio
Posts: 1,040
OS: Windows Server 2003


The way it is setup is:

*This is the My Documents re-direction:

User John Smith:

Home Folder \\server\users\john.smith\my documents

*I want the mapped drive to map the home folder:

\\server\users\john.smith
__________________
Because you can read this thank a teacher, because it's English thank a soldier.
newhouse1390 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 02-23-2007, 02:11 PM   #9 (permalink)
Member, Networking Team
 
Join Date: Jan 2005
Location: Ohio
Posts: 1,040
OS: Windows Server 2003


The above script works! I just need it to not display the error message when the drive is already mapped.
__________________
Because you can read this thank a teacher, because it's English thank a soldier.
newhouse1390 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 02-23-2007, 06:31 PM   #10 (permalink)
Registered User
 
Join Date: Jun 2006
Location: Mid-West
Posts: 111
OS: WinXP Pro


Add the same thing as before

Add:

ON ERROR RESUME NEXT

Put this after variable's are initialized and before the script for mapping drives.
levi.rogers is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 02-23-2007, 09:02 PM   #11 (permalink)
Member, Networking Team
 
Join Date: Jan 2005
Location: Ohio
Posts: 1,040
OS: Windows Server 2003


Thanks, scripts are working and are now active!
__________________
Because you can read this thank a teacher, because it's English thank a soldier.
newhouse1390 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 02-26-2007, 09:41 AM   #12 (permalink)
Registered User
 
Join Date: Jun 2006
Location: Mid-West
Posts: 111
OS: WinXP Pro


Your Welcome.

Glad I could help.
levi.rogers is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 04:39 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85