sconnaug
asked on
Mapping drive to alternate system
I need to map a drive to an alternate system that uses different credentials than windows does. I know I can do the mapping with a net use line in a bat file, however that requests the username / password via commend prompt. I was wondering if anyone had a way to do the mapping via script on Windows 7 that would request the login credentials using the windows security GUI?
Another alternative would be to utilize AutotIt to create the script. The AutoIt function 'DriveMapAdd' handles this nicely. Here is the syntax:
DriveMapAdd("T:", "\\server2\share", 0, "domainname\username", "password")
Where "T" is the letter to map, "\\server2\share" is the servername and share, the '0' makes it persistant, and the rest explains itself.
See this page for complete usage:
http://www.autoitscript.com/autoit3/docs/functions/DriveMapAdd.htm
AuotIt Rocks for this type of task. One word of caution, safegaurd the script, as it will contain a clear text copy of the user's password.
DriveMapAdd("T:", "\\server2\share", 0, "domainname\username", "password")
Where "T" is the letter to map, "\\server2\share" is the servername and share, the '0' makes it persistant, and the rest explains itself.
See this page for complete usage:
http://www.autoitscript.com/autoit3/docs/functions/DriveMapAdd.htm
AuotIt Rocks for this type of task. One word of caution, safegaurd the script, as it will contain a clear text copy of the user's password.
ASKER
I failed to mention the script cannot include the user ID or password, but needs to prompt the user for it. The password changes every 45 days which would be an admin nightmare, not to mention that security would blow a gasket putting that in a script.
I certainly can write a VB script that would have input fields for user name then password. I just thought someone may know a way to utilize the standard windows prompt that the users are familiar with.
I certainly can write a VB script that would have input fields for user name then password. I just thought someone may know a way to utilize the standard windows prompt that the users are familiar with.
I tried an autoit script that was linked to and it doesn't seem to work - anyone have any ideas? I enter credentials that should work and then click okay, but nothing happens.
#include <C:\Program Files\AutoIt3\Include\GuiC onstants.a u3>
#include <C:\Program Files\AutoIt3\Include\Edit Constants. au3>
$gui = GuiCreate("Authenticate",1 20,170)
GUICtrlCreateLabel("Userna me:",10,10 ,50,20)
$username = GUICtrlCreateInput("",10,3 5,100,20)
GUICtrlCreateLabel("Passwo rd:",10,70 ,50,20)
$password = GUICtrlCreateInput("",10,9 5,100,20,$ ES_PASSWOR D)
$go = GuiCtrlCreateButton("OK",1 0,130,50,2 5)
$cancel = GuiCtrlCreateButton("Cance l",60,130, 50,25)
GUISetState()
Do
$msg = GUIGetMsg()
If $msg = $go Then
DriveMapAdd ("Y:","\\aecc\Zdrive",0,$u sername,$p assword)
Exit
EndIf
If $msg = $cancel Then
Exit
EndIf
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GuiDelete($gui)
#include <C:\Program Files\AutoIt3\Include\GuiC
#include <C:\Program Files\AutoIt3\Include\Edit
$gui = GuiCreate("Authenticate",1
GUICtrlCreateLabel("Userna
$username = GUICtrlCreateInput("",10,3
GUICtrlCreateLabel("Passwo
$password = GUICtrlCreateInput("",10,9
$go = GuiCtrlCreateButton("OK",1
$cancel = GuiCtrlCreateButton("Cance
GUISetState()
Do
$msg = GUIGetMsg()
If $msg = $go Then
DriveMapAdd ("Y:","\\aecc\Zdrive",0,$u
Exit
EndIf
If $msg = $cancel Then
Exit
EndIf
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GuiDelete($gui)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Other solutions offered included embedding a user name / password which was unacceptable under our security policies. The solution I entered is not as elegant as we might have liked but it does work.
net use F: \\servername\path password /USER:domain\username
That is assuming you are ok with putting the credentials in the batch file.
If that's not your style, then you could use VB Script to run the same net use command in the background while popping up windows asking for username and password as suggested here:
http://superuser.com/questions/421740/forcing-a-login-script-to-prompt-for-credentials