Prompt for User Credentials in BAT file

How do I ask the user to supply a network username/password when connected to a network via a VPN connection?  For example, I want to run the following command from a BAT file:
xcopy \\<servername>\<sharename>\*.atp "C:\PfX Documents\Binder\Templates\*.*" /D.  It's easy enough when I do the Net Use command and map to a device, since the OS (Win2000/XP) will prompt for a username.  But without running the Net Use command, as in my example, I just get the message "Invalid Drive Specification".  It will work fine if I first do a Run command using \\<servername> and ride username/password.  However, I am trying to prevent the users from doing anything other than connect to the VPN and running a BAT file.  The connecting PC's are not members of the Domain, but the users are.
jforvilleAsked:
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.

Lee W, MVPTechnology and Business Process AdvisorCommented:
Sorry, don't think it can be done as you describe.  You can use net use and I'm not entirely sure why you don't want to.  For example:, this little batch file will do the trick for any NT4/2000/XP system.

net use x: \\server\share * /user:domain\username
xcopy \\<servername>\<sharename>\*.atp "C:\PfX Documents\Binder\Templates\*.*" /D
net use x: /delete
0
Lee W, MVPTechnology and Business Process AdvisorCommented:
The "*" prompts for the user's password.  Actually, this might be a little better for you:

set /p useris=Please Enter Your Username:
net use x: \\server\share * /user:domain\%useris%
xcopy \\<servername>\<sharename>\*.atp "C:\PfX Documents\Binder\Templates\*.*" /D
net use x: /delete
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
tengageCommented:
I'm not real sure what you're asking.  

If you wanted to be very unsecure, you could add the net use to the batch file and give it the ID and password, or you could give it the ID and let the batch prompt for the password.

net use x: \\server\share /u:user password
xcopy x:\*.atp c:\templates\*.*
net use x: /d

If you do the NET USE and don't provide the password, your users will get this in when they launch it

Enter the password for 'user' to connect to 'server':
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

tengageCommented:
wow, we even used the same drive letter
0
Lee W, MVPTechnology and Business Process AdvisorCommented:
Actually as I think about it, if you are copying files via UNC, you don't even need to make a drive letter.  You could do this:

set /p useris=Please Enter Your Username:
net use \\server\share * /user:domain\%useris%
xcopy \\<servername>\<sharename>\*.atp "C:\PfX Documents\Binder\Templates\*.*" /D
net use \\server\share /delete

(Also, the "/p" in the set command will prompt the user with the text following the "=" sign and whatever the user types in will be assigned to "useris")
0
jforvilleAuthor Commented:
Thanks, it was the /p I was looking for.
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
Operating Systems

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.