Link to home
Start Free TrialLog in
Avatar of sgiri
sgiriFlag for United States of America

asked on

startup script to access mapped drive

Hi,I need to access a shared folder from the domain server,as my pc in the work group,whenever i try to access the folder it asks for the username and password to access the shared resources.I am planning to map that folder in my pc and i want to give some startup scripts which automatically run whenever the pc logsin.so that i do not require to put the credentials everytime.Please advice some easy steps which i can use to do this task as i am not in to software programming.
Avatar of Qlemo
Qlemo
Flag of Germany image

Options:
  1. Create a batch file doing the mapping with correct credentials, and put that into your Startup folder.
  2. Make local and domain user the same, using the same password - it will not ask for credentials anymore then.
  3. Do the mapping with correct credentials once, and allow for remembering.
The batch file (e.g. mapdrives.cmd) for 1. would look like this:
net use x: \\server\share /u:MyUser MyPassword /persistent:no
Create that file, and drag it in Explorer to your Startup folder using the start menu (that will create a link).

3. would be implemented by issuing in a Command Prompt or Run box:
net use x: \\server\share /savecred /persistent:yes
Then type your user and password, and that should be stored for all times for this user.

Avatar of SnowWolf
SnowWolf

If you set the workgroup to the same name as the domain, and create a domain account with the same credentials as your local PC account, it wont ask you for a password either.
It is isn't even necessary to have the same workgroup name as the domain name, as long as the server is the domain controller. DCs will automatically apply their domain, if the domain part of a credential is invalid (in most cases, at least). However, having the workgroup name the same makes things much more easy.
Have you tried mapping the drive with a different username?
Greg

map-drive-as-different-user.JPG
That's another way to do it. Remember to have the "Reconnect" checkbox ticked.
Avatar of sgiri

ASKER

Hi Greg,I tried by mapping the drive with a different username,but after the reboot when i try to access the mapped drive it is asking to enter the password.
You need to assign a drive letter for the mapping to be permanent. It does not matter if you use the drive letter later, but the persistent drive settings apply only to mapped drives (as opposed to UNC paths).
ok
this is plan b
open a command prompt change i to the drive letter and change the path
it should ask for a username and password and store them.
net use i: \\ComputerName\ShareName /savecred
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true
this should explain a bit more.
Greg
Avatar of sgiri

ASKER

Hi Greg,I am using the command like this which i found in one of the article.
net use S:(Drive Letter to Map) "\\ECC\ECC-S-SHARED(Share Name)" test(password) /USER:abc\test(domain\username) /persistent:no

the above command gives me error message as conflict with switches and i am not sue abt why persistent is used here.
Please try the /savecred version. /persistent:no is what you want not to use.
if you use the /savecred it will ask for the username and password and save them
next time you map the drive it should know the username and password.
Also
The above command should look more like
net use S: \\ECC\ECC-S-SHARED  /USER:abc\test test /persistent:yes
 
 
Greg
Avatar of sgiri

ASKER

Hi greg,the below command is working for me,but i need to know where to give the savecred
net use r: \\computername\sharename password /USER:dotteddomainname\username /persistent:yes
You can either provide the credentials in net use, as you've done above, or interactively with /savecred, but not both. That is, if you use /savecred, you can't use /user (and password).
BTW, would you please mind reading my first post? All said up to know has already been said there.
Avatar of sgiri

ASKER

Hi Olema,if i use the command i getting the below error mesg.
C:\>net use x: \\pc008\common /savecred /persistent:yes
A command was used with conflicting switches.

More help is available by typing NET HELPMSG 3510.
open this in explorer
C:\Documents and Settings\All Users\Start Menu\Programs\Startup
create a new text file and change the name to map r.bat
 
copy and paste this into the file
 @echo off
echo                 *** Map R drive Script ***
   
net use r: /del

r: \\computername\sharename password /USER:dotteddomainname\username /persistent:yes

 
Does this map the drive without a password?
 
Greg
The above will load at startup for all users and try to map the r drive.
 
Greg
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sgiri

ASKER

Hi Olemo,Yes your correct the commond which you gave in the first post works fine,actually my question was not proper,sorry for that.
1.I tested with a shared folder which has everyone rights it is working fine.
fyi...after given the said command
C:\>net use x: \\pc008\common /savecred /persistent:yes
I am getting the message as mapping done successfully,i didn't asked for the username or password.
2.If i use the same command for the folder which i do not have any rights,i am getting the error message as below.
"A command was used with conflicting switches"
Please note i am using a pc which is in workgroup and i am the administrator for the domaincontroller and i have domai n admin credentials to access the folder.but while mapping it is not asking for any credentials.please help.
what happens if you start run and put the unc path in.
Does it ask for new credentials?
 
Greg
Avatar of sgiri

ASKER

yes Greg,it opens only if i give domain admin credentials.Regards
if you use net use x: \\pc008\common /savecred
does it ask for credentials?
 
Greg
Avatar of sgiri

ASKER

No it does not ask for credentials it immediately gives me the sucessfull message.
Then the credentials have already been saved.
Just use that command in a script and add it to your startup folder and you will always have the drive mapped.
To do this use instructions from above but put your start up folder here
C:\Documents and Settings\your username\Start Menu\Programs\Startup
and use the command that worked.
Greg
Yes, you need to apply that command in each user profile. You cannot do that once and for all as an admin, net use is valid only for an individual and current user.
And credentials are only asked if you do not have a mapping to the same server already, BTW.
Avatar of sgiri

ASKER

As i said earlier,if i try to map the folder which i do not have rights,i am getting error message. "A command was used with conflicting switches"
but if i try to map the folder which i have rights it's working fine.
??? What do you expect ??? You have no rights, so why map it? While the message is confusing, you can't map the drive anyways. If you want an "error-free" mapping, that is silently discarding mapping on folders without rights, add a   2>nul  to the command:

net use x: \\pc008\common /savecred 2>nul

Usually, if you have to map several drives with different shares on the same server, you first do a IPC$ share:

net use \\pc008 /savecred

followed by your intended mappings, without credentials, as they are already provided by the command above:

net use x: \\pc008\common
net use y: \\pc008\private
net use * \\pc008\ChangingDriveLetter
Avatar of sgiri

ASKER

sorry for that, the requirement is.
I have a DC @ location "A" and DC @ location "B",both the DC's working independently.but the network is connected with site 2 site.
From location "A" if i try to access the folder from location "B" which doesn't have rights for the user of location "B" server.
If I use $sign and give the admin credentials i will be able to access the folder manually,
but i want to map this permanently even if the server reboots the map should reconnect automatically.

Regards
giri
That does not make it more clear. You really want to have all users on "A" to use admin shares ($'s) on "B"? That will indeed only work with an admin account. And then they can access anything on that server. That is nothing I would want to do.
Avatar of sgiri

ASKER

Thanks