Re: Mapping drives and request logon credentials



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.

.



Relevant Pages

  • Re: password protect computers on workgroup
    ... I will create a username called tester and give it a rights to the shared folder. ... Posting on MS newsgroup will benefit all readers and you may get more help. ... we have our shared folders set up so that network users are not ...
    (microsoft.public.windowsxp.network_web)
  • Re: Problems accessing network share
    ... I have a shared a shared folder on one of my Windows XP ... >assigning permissions to it (aka a username and password for accessing it). ... With Simple File Sharing disabled on any computer acting as a server, ...
    (microsoft.public.windowsxp.network_web)
  • Re: Trouble sharing a folder on a Windows Server 2003 server
    ... - Create username for each of your users. ... Assign appropriate Share Level permission on the share. ... username and password must be the same on the server side and on ... On all six when I map a shared folder that is on one of the two partitions ...
    (microsoft.public.windows.server.general)
  • Problems accessing network share
    ... I have a shared a shared folder on one of my Windows XP ... Pro machines, which I have secured by disabling “Simple File Sharing” and ... assigning permissions to it (aka a username and password for accessing it). ...
    (microsoft.public.windowsxp.network_web)
  • Re: Logon
    ... reset Environment Variables ... > The easiest way is to check the environment variable Username; ... > "Alvin Hansen" wrote: ... >> currentusername i get "admin" and not my name i ...
    (microsoft.public.access.modulesdaovba)

Loading