Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 604
  • Last Modified:

Win7 Drive Mapping doesn't work in VBScipt

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
schmir1
Asked:
schmir1
3 Solutions
 
yelbaglfCommented:
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
 
skipper68Commented:
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
 
mwadminCommented:
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
 
schmir1Author Commented:
All good answers.  I was hoping to somehow get WScript.ScriptFullName to work but your answers will work.
0

Featured Post

Industry Leaders: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now