Solved

Win7 Drive Mapping doesn't work in VBScipt

Posted on 2011-02-10
4
596 Views
Last Modified: 2012-05-11
I CANNOT use my drive mapping to locate files in Win7.  For example the following script runs:
   oFSO.copyfile "\\ent\mit-msp01\Crm-pdsbsmapps\MCL_Dbase\Setup\vbSendMail.DLL",
            "c:\DTL Database\vbSendMail.DLL", True

But the following does not?
  oFSO.copyfile "T:\MCL_Dbase\Setup\vbSendMail.DLL", "c:\DTL Database\vbSendMail.DLL", True

To fix the problem, I had to replace T drive for the full server path.
Note: T does show up correctly in Windows Explorer

I also can't use WScript.ScriptFullName because of this.
Anyone know of a cure?  I need to get this script running on my 50 user's PCs       
0
Comment
Question by:schmir1
4 Comments
 
LVL 11

Accepted Solution

by:
yelbaglf earned 167 total points
ID: 34868109
I had a similar issue, and what I did was create a couple of variables for my copy source and destination.

objSource = "source"
objDest = "dest"
oFSO.copyfile objSource, objDest, True
0
 
LVL 9

Assisted Solution

by:skipper68
skipper68 earned 167 total points
ID: 34868121
You can try this.  This one will let you map multiple drives with an array.

'create and populate an array with mapping information.
'Enter drive letter, path and friendly name separated by pound signs.
'Note the H drive sample maps to the users share
Dim driveArray()
ReDim Preserve driveArray(0)
driveArray(0) = "H:#\\Server\Users\" & UserString & "#Home Drive"
ReDim Preserve driveArray(1)
driveArray(1) = "S:#\\Server\Scripts#Scripts"
ReDim Preserve driveArray(2)
driveArray(2) = "X:#\\Server\Executables#Program Install Files"

KeyBase ="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\"

For Each drive In driveArray
      thisMap = Split(drive,"#")
      strDriveLetter = thisMap(0)
      strRemotePath = thisMap(1)
      strNewName = thisMap(2)
      
      ' Section to map the network drive
      WSHNetwork.MapNetworkDrive strDriveLetter, strRemotePath
      
      ' Section which actually (re)names the Mapped Drive
      Key = Replace(strRemotePath,"\","#")
      WSHShell.RegWrite KeyBase & Key & "\_LabelFromDesktopINI", strNewName, "REG_SZ"
Next
0
 
LVL 3

Assisted Solution

by:mwadmin
mwadmin earned 166 total points
ID: 34868643
Try add this to the script, not where you need to put your copy command in;

Dim WshShell
Dim objShell
Dim objNetwork
Dim strDriveLetter1
Dim strRemoteName1
set WshShell = WScript.CreateObject ("WScript.Shell")
set objNetwork = WScript.CreateObject ("WScript.Network")
strDriveLetter1 = "T:"
strRemoteName1 = "\\ent\mit-msp01\Crm-pdsbsmapps"
objNetwork.MapNetworkDrive strDriveLetter1, strRemoteName1
~~~INSERT YOUR COPY SECTION HERE~~~
objNetwork.RemoveNetworkDrive strDriveLetter1
wscript.quit
0
 

Author Closing Comment

by:schmir1
ID: 34964717
All good answers.  I was hoping to somehow get WScript.ScriptFullName to work but your answers will work.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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