Solved

How to make drives persistent in vbs logon script?

Posted on 2008-06-24
11
581 Views
Last Modified: 2010-04-16
How to made the below mapping  persistent
----------------------------------------------------------------------------------------------------
Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath
strDriveLetter = "w:"
strRemotePath = "\\server1\xyz"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
WScript.Echo " Launch Explorer, check: "& strDriveLetter
WScript.Quit
--------------------------------------------------------------------------------------------------
0
Comment
Question by:Jameseka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
11 Comments
 
LVL 13

Expert Comment

by:TheCapedPlodder
ID: 21853313
Add the bUpdateProfile value and set it to True as below:

objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, True


Cheers,

TCP
0
 

Author Comment

by:Jameseka
ID: 21853327
Can you complete the code ?

------------------------------------------------------------------------------------------------
Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath
strDriveLetter = "w:"
strRemotePath = "\\server1\xyz"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
WScript.Echo " Launch Explorer, check: "& strDriveLetter
WScript.Quit
------------------------------------------------------------------------------------------------
0
 

Author Comment

by:Jameseka
ID: 21853333
Oh I got it
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:TheCapedPlodder
ID: 21853450
------------------------------------------------------------------------------------------------
Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath
strDriveLetter = "w:"
strRemotePath = "\\server1\xyz"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, True
WScript.Echo " Launch Explorer, check: "& strDriveLetter
WScript.Quit
------------------------------------------------------------------------------------------------
0
 

Author Comment

by:Jameseka
ID: 21853720
the mapping disappear after the reboot.
0
 
LVL 13

Expert Comment

by:TheCapedPlodder
ID: 21853756
OK.

Well the bUpdateProfile value is the equivalent of /PERSISTENT:YES in net use so there must be some other factor at work.

Why don't you just run this as a login script rather than rely on persistency which is always a bit hit and miss?

Have you tried using a batch file (which is far simpler):

net use w: \\server1\xyz /PERSISTENT:YES

Cheers,

TCP

0
 

Author Comment

by:Jameseka
ID: 21862228
I know this command but VB scrip is what I need.
0
 
LVL 13

Accepted Solution

by:
TheCapedPlodder earned 500 total points
ID: 21863440
OK, two things.

If you must use VBScript then why not run it as a logon script so that the drive maps every time the user logs in and therefore you don't need to worry about persistency.

If that is unacceptable why not use net use as a troubleshooting step and see if the drive mapping is retained.  This will tell you whether something else is causing the drive mappings to be lost.
0
 
LVL 13

Expert Comment

by:TheCapedPlodder
ID: 21863503
I have provided the answer to your initial question and tried to help you beyond your initial issue.  You appear not to want to spend any effort on solving your own issue and that's fine however I should be awarded the points for providing a perfectly workable solution.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question