Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Win7 Drive Mapping doesn't work in VBScipt

Posted on 2011-02-10
4
Medium Priority
?
601 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Accepted Solution

by:
yelbaglf earned 668 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 668 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 664 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

715 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