Solved

Win7 Drive Mapping doesn't work in VBScipt

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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