Batch file---Map network drive authenticating with UN and PW

I have a small XP network (Workgroup) with a network hard-drive that we are using for a backup. My predecessor created a backup schedule thru Robocopy but my problem is that the network drive is password protected and the backup fails each evening with Access is denied.
The backup is from a single XP machine acting as a file server. The system has multiple users who log in and out with the same mapped drive to the backup drive, but when users log out it drops the mapped drive.
So I need to add some commands to the batch file. Mapping the network drive and authenticating with the username and password. Then waiting a few seconds before continuing with the backup.
Is this possible with a Batch file? I have searched the internet and am coming up blank.

The IP of the network drive is the 192.168.168.210. Below is the batch file as it currently stands:
ping 192.168.168.210
robocopy "C:\Investments" "I:\BACKUPS" /MIR /V /NP /R:10 /W:5 /log:C:\Nightly_Backup_log.txt


Thanks in advance for any help.
AZHenryAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hlarseCommented:
Try this:

net use i: \\server\share /user:userid password
ping -n 6 127.0.0.1 >nul
robocopy "C:\Investments" "I:\BACKUPS" /MIR /V /NP /R:10 /W:5 /log:C:\Nightly_Backup_log.txt

The ping functions as a pause.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
You don't need to pause after mapping a drive, it is either mapped or not but otherwise as hlarse says.

You can also do it by scheduling the backup task as, say, a local username called "userid" with a password of "password" (obviously use real values here) which matches the userid and password on the machine to be backed up to.  Then if you backup using

robocopy "c:\investments" "\\otherpcname\share" /MIR .... etc.

it should work as it will use current username and password to access the UNC

hth

Steve
0
AZHenryAuthor Commented:
Hlarse
It worked like a charm, mapped the drive and authenticated with no glitches. I didnt run robocopy but am sure it will go thru tonight. Thank You


Dragon-it
Also thank you for your input as well, as to batch files this has been a good learning experience and I appreciate your suggestions.

Im going to award all points to hlarse since his was the 1st response and provided exactly what I needed.

 Henry
0
Steve KnightIT ConsultancyCommented:
Fair enough.... 3 minutes late, was just about to post but saw hlarse's first :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.