• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1107
  • Last Modified:

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.
0
sgiri
Asked:
sgiri
  • 13
  • 10
  • 8
  • +1
1 Solution
 
QlemoDeveloperCommented:
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.

0
 
SnowWolfCommented:
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.
0
 
QlemoDeveloperCommented:
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.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
greg wardSystems EngineerCommented:
Have you tried mapping the drive with a different username?
Greg

map-drive-as-different-user.JPG
0
 
QlemoDeveloperCommented:
That's another way to do it. Remember to have the "Reconnect" checkbox ticked.
0
 
sgiriAuthor Commented:
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.
0
 
QlemoDeveloperCommented:
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).
0
 
greg wardSystems EngineerCommented:
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
0
 
QlemoDeveloperCommented:
... see http:#a29544012
0
 
sgiriAuthor Commented:
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.
0
 
QlemoDeveloperCommented:
Please try the /savecred version. /persistent:no is what you want not to use.
0
 
greg wardSystems EngineerCommented:
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
0
 
sgiriAuthor Commented:
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
0
 
QlemoDeveloperCommented:
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).
0
 
QlemoDeveloperCommented:
BTW, would you please mind reading my first post? All said up to know has already been said there.
0
 
sgiriAuthor Commented:
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.
0
 
greg wardSystems EngineerCommented:
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
0
 
greg wardSystems EngineerCommented:
The above will load at startup for all users and try to map the r drive.
 
Greg
0
 
QlemoDeveloperCommented:
Cross-checked (again) with Vista and XP, both work exactly with the above syntax with savecred. Strange.
0
 
sgiriAuthor Commented:
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.
0
 
greg wardSystems EngineerCommented:
what happens if you start run and put the unc path in.
Does it ask for new credentials?
 
Greg
0
 
sgiriAuthor Commented:
yes Greg,it opens only if i give domain admin credentials.Regards
0
 
greg wardSystems EngineerCommented:
if you use net use x: \\pc008\common /savecred
does it ask for credentials?
 
Greg
0
 
sgiriAuthor Commented:
No it does not ask for credentials it immediately gives me the sucessfull message.
0
 
greg wardSystems EngineerCommented:
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
0
 
QlemoDeveloperCommented:
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.
0
 
QlemoDeveloperCommented:
And credentials are only asked if you do not have a mapping to the same server already, BTW.
0
 
sgiriAuthor Commented:
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.
0
 
QlemoDeveloperCommented:
??? 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
0
 
sgiriAuthor Commented:
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
0
 
QlemoDeveloperCommented:
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.
0
 
sgiriAuthor Commented:
Thanks
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.

  • 13
  • 10
  • 8
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now