Net Use to Map Drives on login

Associate
Joined
27 Feb 2006
Posts
1,750
Location
Normanton
Im trying to write a bat file to map drives to my file server on login but im getting some problems this is what ive got

Code:
@echo off
net use z: /delete
net use x: /delete
net use y: /delete

set "svrname=home"
set "usr=matt"
set "pwd=test"

for /f "tokens=2" %%# in ('net use^|find /i "\\%svrname%"') do net use %%# /delete>nul

net use Z: \\%svrname%\Media /user:%usr% "%pwd%">nul

net use X: \\%svrname%\Downloads /user:%usr% "%pwd%">nul

net use Y: \\%svrname%\Backup /user:%usr% "%pwd%">nul

It works most of the time but im getting an error saying

"multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again."

How can I see what previous connections I am making as I don't think I am doing and stop them?

Cheers
 
You could just do this on login but make sure the user logged on has the same password as what the server username/password has for that share.

Code:
;LOGIN
@echo off

net use X: \\server01\Media                                          
net use Y: \\server01\Downloads
net use Z: \\server01\Backup

Code:
;LOGOFF
@echo off
NET USE X: /DELETE
NET USE Y: /DELETE
NET USE Z: /DELETE

Simple but effective, which works to a simple unc path.
 
Im trying to do it from my pc which is logged on with a different user, I'll try and show what i mean

My PC (single user no password) ---------->lan---------->Home server logged in as matty (admin) but with local user mat created with write access to drives want to share
 
Alright then, in that case are you using the script on multiple workstations?

Not yet but that was the plan as I have 2 media centres 1 laptop and another pc that I want to setup the same way so all can see the shares

Ive created different users on the server for each though as some only need read access and was just going to change the username + pass for each script
 
Im trying to do it from my pc which is logged on with a different user, I'll try and show what i mean

My PC (single user no password) ---------->lan---------->Home server logged in as matty (admin) but with local user mat created with write access to drives want to share

Code:
NET USE X: \\SERVER\SHARE /USER:localuser password

and remember to add the user to the server localuser/password and give permissions for localuser to access that folder (if it makes sence).
 
Code:
NET USE X: \\SERVER\SHARE /USER:localuser password

and remember to add the user to the server localuser/password and give permissions for localuser to access that folder (if it makes sence).

Cheers that works fine but the problem is when I reboot and I get 2 things the pc hangs for ages dont know what its doing as im still waiting for it! typing this from laptop and it wont reconnect to the drives even if I specify /PERSISTENT:yes Vista just brings a box up saying cannot connect to all network drives
 
Cheers that works fine but the problem is when I reboot and I get 2 things the pc hangs for ages dont know what its doing as im still waiting for it! typing this from laptop and it wont reconnect to the drives even if I specify /PERSISTENT:yes Vista just brings a box up saying cannot connect to all network drives

did you do a logoff script where it disconnects the drives at logoff?
 
Back
Top Bottom