Question

Locked

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

By kbosworth ·
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

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

clarify

by robo_dev In reply to how to make .bat file ask ...

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?

Collapse -

You could include them in the commmand line

by 1bn0 In reply to how to make .bat file ask ...

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.

Collapse -

Thank You

by kbosworth In reply to You could include them in ...

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

Collapse -

Yes.

by cmiller5400 In reply to Thank You

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.

Collapse -

Am I missing something?

by Brenton Keegan In reply to how to make .bat file ask ...

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.

Back to Software Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums