Solved

Win7 Drive Mapping doesn't work in VBScipt

Posted on 2011-02-10
4
591 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now