Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Map Network Drives 1

Status
Not open for further replies.

jc999

Technical User
Oct 20, 2003
35
GB
Hi,

I'm trying to use a logon script to map a network drive for each user that we have in a particular OU. I tried to use:

Set objNetwork = Wscript.CreateObject("WScript.Network")
objNetwork.RemoveNetworkDrive "S:"
objNetwork.MapNetworkDrive "S:", "\\server\documents"

The problem i have is that about half of the users have their drives mapped already - and half don't. If i just use the last line i get errors that it is already mapped, and if i include the penultimate line i get errors where there is no network drive to remove.

I assume i need to use an if statement- although i do not see what I can test. Would appreciate any good scripting - my knowledge of scripting isn't too good
 
I'd just put an "on error resume next" after the set line, and an "on error goto 0" after the MapNetworkDrive line.

That should do the trick for you.

Denny

--Anything is possible. All it takes is a little research. (Me)
 
Seems you have trouble with persistent drivemappings (which you _as administrator_ don't want because it gives you headaches managing.

Have a look it this and include it in your loginscript (first remove all persistent mappings and after that map the drivemappings you do want)

 
Thanks to both, used the first one as I already had most of the code there. Just what I wanted - thanks
 
no problem.

Denny

--Anything is possible. All it takes is a little research. (Me)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top