Solved

How to make drives persistent in vbs logon script?

Posted on 2008-06-24
11
572 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
  • 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
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!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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