Mapping a drive
I want to map a drive on a computer on another network, so it has a different domain, but it has dual network cards so there's an IP for it on our range. I need to specify the details to connect to this drive rather than use my normal login credentials. Is there a script that can be run at logon to do this? Any pointers?
I assume something like net use S: \\server\folder but how do I give the login details?
should do it, see
net use S: \\server\folder /user:domain\username /password:password
for more details
It should be
That should work.
net use s: \\server\share /user:domain\username password:password
As we have command prompt disabled though how can I get it to play happy? Atm I suspect it'll come up with 'command prompt disabled'.
Edit: Ah, if I run it as a logon script, it might be different.
If it's set as a logon script through GPO it should still run. CMD is disabled for our students but the mapped drives here still run.
If it's for a single user (whose currently logged in) or a one off - you should be able to do it via the GUI. Windows should prompt for the username and password and their should be tick boxes to reapply at login and remember password.
If it's a regular thing for all users then @bladedanny is right, put it in a logon.bat file.
As per --> MapNetworkDrive | VBScript | SS64.com
False in the above command is to set if it is persistently mapped so if you need it to be persistent then just change this to True
Dim objNetwork, strUser, strPassword
Set objNetwork = WScript.CreateObject("WScript.Network")
strLocalDrive = "S:"
strRemoteShare = "\\myserver\Directory"
strUser = "Domain\Username"
strPassword = "MyPasswordHere"
objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, False, strUser, strPassword
Although should do the same as the above mentioned bat file :)
I trued the BAT file option and placed it in scripts on Sysvol but it hung when the user tried to log in. Hmm?
Tried just using this too in the hope it would pop up asking for auth but same thing.
net use u: \\IP\share$
The vb script any different or does that do the same ?
Obviously open notepad, copy and paste code and adjust relevant bits ( domain\username, password, drive letter and the mapped path etc ), save as and in the filename text field when you are going to save it, type something along the lines of
Click Save and copy the script to the relevant sysvol area or wherever and assign as a logon script etc and try again
Spot on with the VBS :-)
Thanks so much all.
Hmm. I want the drive to be available to multiple users but it seems to complain because the same credentials are being used by multiple people to map the drive. Any advice?