Question Locked

how to make .bat file ask for user name and password

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Does anyone know how to force a login script to ask for user name and password to connect networkdrives and printers to a non network computer i am using a .bat file for drives and VBScript for printers i.e.

net use U: /home
net use H: /d
net use H: \\DOMAINSERVER\common
net use I: /d
net use I: \\DOMAINSERVER\engineering
net use N: /d
net use N: \\DOMAINSERVER\Logs
net use R: /d
\\DOMAINSERVER\netlogon\scripts\jocks.vbs
call \\DOMAINSERVER\netlogon\dns\regdns.bat

now i need another element to make it ask for UN & Pass

Please help

6 replies

by robo_dev

if the batch file tries to connect to a protected resource, Windows will pop up the authentication dialog all by itself, no?

Or do you want to script whole thing by getting userid/password ahead of time?

by 1bn0

net use h: \\[Server Name]\[Share Name] /user:[Logon Server]\[User Name] [Password] /persistent:no

The [Logon Server] can simply be the name of the machine you are connecting to with a local user account name for [User Name}

But this method would mean anyone with access to the script folder could read the batch file and see the username and password.

I only use this for non-standard drive mappings under a specific user profile and put the batch file in the users startup folder.

You shouldn't need to use batch files for net use and .vbs for printers. It can all be done in the .vbs script.

by kbosworth

so i could actually modify my current script and put it into thier startup folder is this assumption correct

by cmiller5400

Also, if you use the vbs scripting, you can use "screnc" to encrypt the text so that it isn't in plain text for the username and password.

by brenton keegan

Am I missing something but isn't the whole idea of a login script is that it happens when you login? So that means that the user would need to authenticate to the domain before the script is run.

It seems to me that it already does what you are trying to script it to do.

Also, why don't you just run the whole thing in vbscript? It's much better at this sort of thing than a batch file.

The WshNetwork object contains many methods that I think you would find useful:
http://msdn.microsoft.com/en-us/library/s6wt333f%28VS.85%29.aspx

If you only want certain users to have the network drive mapping I would do it by group membership. Active directory information is stored in a queryable database. You can set a conditional in your script that only maps the drive if a user is a member of a particular group.

This discussion is closed to new replies.