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?
 
Lee W, MVPConnect With a Mentor Technology 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
 
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
 
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
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
All Courses

From novice to tech pro — start learning today.