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

x
?
Solved

VBS script multiple copy of files to Mapped Drives

Posted on 2009-07-14
5
Medium Priority
?
345 Views
Last Modified: 2012-05-07
Hello,

I am currently trying to copy one file to multiple drives using a VBS script I have the code for copy to one drive but would like to make it copy file to multiple at the same time. The drive letters that I am using are P > X

Any help would be greatly appreciated as I seem to be having a issue with this.. Thanks

I have attached current code as a example
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\test.exe" , "P:\", OverwriteExisting

Open in new window

0
Comment
Question by:ITCSHRPK
[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
  • 3
  • 2
5 Comments
 
LVL 38

Expert Comment

by:Shift-3
ID: 24852096
This should do it.


Const OverwriteExisting = True
 
For i = 80 To 88
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.CopyFile "C:\test.exe" , Chr(i) & ":\", OverwriteExisting
Next

Open in new window

0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 1000 total points
ID: 24852385
To elaborate, I used the Asc function to get the decimal ASCII value of the letters P and G, e.g.
WScript.Echo Asc("P")WScript.Echo Asc("X")

This returns values of 80 and 88.  (There are also tables available online where you can look these up.)

I then used a For...Next loop to iterate through the numbers 80-88.

The Chr function converts from the ASCII value back to the character.
0
 

Author Comment

by:ITCSHRPK
ID: 24852441
Thanks Sage..

If I wanted to change this up a bit and have it actually copy to a IP on a seperate Domain how would I go about that. This will end up being scheduled to run in the early hours of the morning.

The current process that I have is Map the drives - Copy the files - Remove the Drive mapping.. all items are completed via a VBS file.

Thanks
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 24853147
You would do better to skip mapping the drives and just copy the files using the UNC paths.

You could put the target paths in an array and then copy to each of them, as below.  Run the scheduled task under an account which has permission to write to the destinations.


Const OverwriteExisting = True
 
arrTargets = Array("\\192.168.100.100\share\","\\192.168.100.101\share\")
 
For Each strTarget in arrTargets
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.CopyFile "C:\test.exe", strTarget, OverwriteExisting
Next

Open in new window

0
 

Author Comment

by:ITCSHRPK
ID: 24853264
Thanks again Sage.. Much appreciated will give that a shot and see how it goes..
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

661 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