?
Solved

Script for Mapping drives in vb script

Posted on 2006-05-11
4
Medium Priority
?
134 Views
Last Modified: 2010-05-01
Hey guys i have a vbscript that i am currently using as logon script for a client. Right now this is the script that i am using(below) but instead of auto deleting and remapping the drives i want the script to check to see if the mapping is correct and if it is leave it alone but if it isnt correct then the script will delete and remap.
Any help would be graciously appreciated !!!

Option Explicit
On Error Resume Next
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.RemoveNetworkDrive "H:"
WshNetwork.RemoveNetworkDrive "I:"
WshNetwork.RemoveNetworkDrive "K:"
WshNetwork.MapNetworkDrive "H:", "\\win2003\USERS"
WshNetwork.MapNetworkDrive "I:", "\\win2003\COMMON"
0
Comment
Question by:jjeffords
2 Comments
 
LVL 6

Accepted Solution

by:
junglerover77 earned 1500 total points
ID: 16664347
What do you mean by "i want the script to check to see if the mapping is correct" ?

Do you mean, you wanna know if the mapping is succeeded or not?

To check if the mapping is succeed or not, you can just check Err.Number. Just like this:

Option Explicit
On Error Resume Next
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.RemoveNetworkDrive "H:"
WshNetwork.RemoveNetworkDrive "I:"
WshNetwork.RemoveNetworkDrive "K:"

WshNetwork.MapNetworkDrive "H:", "\\win2003\USERS"
if Err.Number=0 then
    Msgbox "Map Succeeded!"
else
    Msgbox "Map Failed!"
end if
0
 
LVL 14

Expert Comment

by:MilanKM
ID: 16666482
See the following link, may u get some help there regarding your problem,
http://www.computerperformance.co.uk/Logon/Logon_HomeDir.htm

Thanks
MilanKM
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

840 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