We help IT Professionals succeed at work.

When using VBScript:  nUser.MapNetworkDrive "I:", "\\Server\Share", how do you make the drive persistant?

ellsworth2000
on
Medium Priority
489 Views
Last Modified: 2007-12-19
Good Day Experts,

When using VBScript:  nUser.MapNetworkDrive "I:", "\\Fax\Scans", how do you make the drive persistant?  This is the whole script:

On Error Resume Next

'
' Set constants and variables
'

Dim wshShell
Dim Domain
Dim UserName
Dim nUser

Set wshShell = WScript.CreateObject("Wscript.Shell")
Set nUser = WScript.CreateObject("Wscript.Network")

Domain = nUser.UserDomain
UserName = nUser.UserName

'
' Map Company Folder
'

nUser.MapNetworkDrive "I:", "\\Server\Share"
nUser.MapNetworkDrive "J:", "\\Server\Share2"

'
'Clean Up
'
Set UserName=Nothing
Set nUser=Nothing
Set Domain=Nothing
_____________________________________End Script


Comment
Watch Question

Chris DentPowerShell Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:

Hi,

You need to update the profile with the mapping. MapNetworkDrive accepts a third parameter for that:

objNetwork.MapNetworkDrive strDrive, strShare, True

The default for that is False (which is non-persistant).

Chris

Author

Commented:
Thank You for your Reply Chris-Dent,

what is the profile?  And where should the:  objNetwork.MapNetworkDrive strDrive, strShare, True be inserted to?

Many Thanks,

Ellsworth
PowerShell Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:

The profile is the user profile, it basically writes it to the user profile making the mapping persistant.

This is the translation to the syntax in your script:

nUser.MapNetworkDrive "I:", "\\Server\Share", True
nUser.MapNetworkDrive "J:", "\\Server\Share2", True

Basically just add the third parameter onto each of the mappings you're doing. Sorry for the confusion.

Chris

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Perfect!!!  Thanks Chris.
Chris DentPowerShell Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:

No problem :)

Chris
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.