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

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


ellsworth2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris DentPowerShell DeveloperCommented:

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
0
ellsworth2000Author 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
0
Chris DentPowerShell DeveloperCommented:

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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ellsworth2000Author Commented:
Perfect!!!  Thanks Chris.
0
Chris DentPowerShell DeveloperCommented:

No problem :)

Chris
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.