Maps a network drive.
DriveMapAdd ( "device", "remote share" [, flags = 0 [, "user" [, "password"]]] )
device | The device to map, for example "O:" or "LPT1:". If you pass an empty string for this parameter a connection is made but not mapped to a specific drive. If you specify "*" an unused drive letter will be automatically selected. |
remote share | The remote share to connect to in the form "\\server\share". |
flags | [optional] A combination of the following: $DMA_DEFAULT (0) = default $DMA_PERSISTENT (1) = Persistent mapping $DMA_AUTHENTICATION (8) = Show authentication dialog if required Constants are defined in "AutoItConstants.au3" |
user | [optional] The username to use to connect. In the form "username" or "domain\username". |
password | [optional] The password to use to connect. |
Success: | 1. (See Remarks) |
Failure: | 0 if a new mapping could not be created and sets the @error flag to non-zero. |
@error: | 1 = Undefined / Other error. @extended set with Windows API return 2 = Access to the remote share was denied 3 = The device is already assigned 4 = Invalid device name 5 = Invalid remote share 6 = Invalid password |
Note: When using "*" for the device parameter the drive letter selected will be returned instead of 1 or 0, e.g. "U:". If there was an error using "*" then an empty string "" will be returned.
If defined the user/password will be presented to the remote computer that will validate the credential.
#include <AutoItConstants.au3>
; Map X drive to \\myserver\stuff using current user
DriveMapAdd("X:", "\\myserver\stuff")
; Map X drive to \\myserver2\stuff2 using the user "jon" from "domainx" with password "tickle"
DriveMapAdd("X:", "\\myserver2\stuff2", $DMA_DEFAULT, "domainx\jon", "tickle")