Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Scenario: Office is transferring from one server to another, on a different domain than is currently being used. Net use login scripts fail automatically due to improper authentication.

What I need A login script to map drives to the new server, using different credentials than what the user logs in with. Cannot put username and password for each user in the login script, it needs to prompt and allow a user to modify the domain/username and password to gain access to it.

What it would look like Login script runs, opens a window prompting for the user to input alternative credentials, user inputs required credentials, drive maps properly.

I have done some google searches, and looked into vbs net use scripting, but it looks like it all requires the user's username and password to be put into the specific login batch file.


share|improve this question
up vote 4 down vote accepted

With VBS scripting, you could use something like

$username = InputBox("Type your username", vbOKOnly)
$password = InputBox("Type your password", vbOKOnly)
share|improve this answer
Would you mind elaborating a bit more on the syntax, possibly provide an example using something like Contoso? – francisswest May 7 '12 at 21:24
@francisswest Unfortunately, I don't know what Contoso is. Basically, setup a variable (i.e. $username and $password), and the output of the InputBox will be put into that variable. You can then use $**variable** in your script, so that the Username and Password are not hard-coded. The part between the quotation marks is the message that comes up, the vbOKOnly part makes only an OK button appear on the dialog. The dialog will ask the question and provide 1 text field – Canadian Luke May 7 '12 at 21:40
No problem, Contoso is one of Microsoft's fictitious companies that it uses in examples while teaching how to do something. So instead of using a domain name that actually exists (if you dont want your domain name to be published necessarily, you could rig up an example using Contoso. I.e. (then the user plugs in the actual domain to get a working script) Either way, the information you have provided looks extremely promising. I will run it by the sysadmin and see what he thinks about it. Thanks! – francisswest May 7 '12 at 21:57

Here is an example of how you would do that in AutoIt. This will prompt for credentials and then persistently map a drive based on those credentials.

#include <GuiConstants.au3>
#include <EditConstants.au3>

$gui = GuiCreate("Authenticate",120,170)

$username = GUICtrlCreateInput("",10,35,100,20)
$password = GUICtrlCreateInput("",10,95,100,20,$ES_PASSWORD)

$go = GuiCtrlCreateButton("OK",10,130,50,25)
$cancel = GuiCtrlCreateButton("Cancel",60,130,50,25)

    $msg = GUIGetMsg()

    If $msg = $go Then
        DriveMapAdd ("K:","//path/to/share",1,$username,$password)

    If $msg = $cancel Then

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.