Solved

How to make drives persistent in vbs logon script?

Posted on 2008-06-24
11
566 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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