Re: Mapping drives and request logon credentials
- From: dNagel <NOTGrandNagel@xxxxxxxxxxx>
- Date: Tue, 21 Nov 2006 09:54:11 -0800
below is the relevant text of this link...
http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_peht.mspx?mfr=true
MapNetworkDrive has three optional arguments... You are going to have to prompt
the user for their username ( \\domain\user ) and password independently and then pass
them into this function.
This is by no means very secure because you're not using windows dialogs but it will
get the job done.
Mapping a Network Drive
You map a local drive letter to a shared folder using the WshNetwork objects MapNetworkDrive method. You can use MapNetworkDrive to connect directly to a shared folder or any child folder beneath a shared folder. MapNetworkDrive has two mandatory and three optional arguments, defined in Table 3.22.
*Table 3.22 MapNetworkDrive Arguments*
Argument Type Required Default Description
LocalName
String
Table Bullet
None
The drive letter, followed by a colon, assigned to the mapped network drive, e.g., "H:".
RemoteName
String
Table Bullet
None
The shared folders UNC name, e.g., "\\ServerName\ShareName" or "\\ServerName\ShareName\FolderName".
UpdateProfile
Boolean
False
Boolean value indicating whether the mapping information is stored in the current users profile. The value True updates the current users profile; False does not.
UserName
String
None
Maps the network drive using the credentials of someone other than the current user.
Password
String
None
Password for the user identified by the UserName argument.
The following example demonstrates how MapNetworkDrive can be used in a users logon script to connect to two network shares.
Set objNetwork = Wscript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "G:", "\\atl-fs-01\Sales"
objNetwork.MapNetworkDrive "H:", "\\atl-fs-01\Users$\lewjudy"
The examples do not show the full use with username/pw but all you have to do is tack
on a true or false, and two more string variables.
The user name can be retrieved from the DOS environment variables, but thats not all that
easy because the environ variable (I don't think) is not available in VBScript.
You can create a batch file on the fly and have it pipe the results of the desired var back into
a file and then open that file if you want to get into more advanced scripting, otherwise
just ask them for the appropriate values.
D.
.
- References:
- Mapping drives and request logon credentials
- From: altria
- Mapping drives and request logon credentials
- Prev by Date: Re: Read file from Server
- Next by Date: Re: If user logging on exist in \\server\file.txt then install patch
- Previous by thread: Re: Mapping drives and request logon credentials
- Next by thread: Launching a Messenger window
- Index(es):
Relevant Pages
|
Loading