?
Solved

How to make drives persistent in vbs logon script?

Posted on 2008-06-24
11
Medium Priority
?
595 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

649 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