Missing Flash Drive Aborts VBScript Copying

December 7, 2010 at 18:28:00
Specs: Windows XP-Pro SP3, 2.0 GHz, 512MB
I use the VBScript below to copy files and folders to different drives. This script allows my folders to retain their custom icons when copied. One of the destination folders "N:\APPS" is on a USB flash drive . I have discovered if my flash drive is not connected the script aborts the copying process when it can't find the drive. I would like to know if the script can be modified to ignore non existing destinations and continue to copy to the other valid destinations. I realize I could write the script so the copying to the flash drive would be the last operation but I am interested in finding out if this script could be modified as I explained above.

On Error Resume Next
Const OverwriteExisting = True
set args = wscript.Arguments  
set objShell = CreateObject("Shell.Application" )  
 
Set objFolder = objShell.NameSpace("D:\Program Files" ) 
if not objFolder is nothing then  
for each item in args   
objFolder.CopyHere item, 16  
next  

Set objFolder = objShell.NameSpace("N:\APPS" ) 
if not objFolder is nothing then  
for each item in args   
objFolder.CopyHere item, 16  
next  

Set objFolder = objShell.NameSpace("W:\APPS" ) 
if not objFolder is nothing then  
for each item in args   
objFolder.CopyHere item, 16  
next  

Set objFolder = objShell.NameSpace("X:\APPS" ) 
if not objFolder is nothing then  
for each item in args   
objFolder.CopyHere item, 16  
next  

End If 
End If 
End If 
End If 


See More: Missing Flash Drive Aborts VBScript Copying

Report •

#1
December 8, 2010 at 10:12:25
My Problem was solved on another forum.
Here is the link:
http://www.tek-tips.com/viewthread....

This script given to me there works perfectly.


set args = wscript.Arguments  
set objShell = CreateObject("Shell.Application" )  

Set objFolder = objShell.NameSpace("D:\Program Files" )
if not objFolder is nothing then  
 for each item in args   
  objFolder.CopyHere item, 16  
 next  
End If
Set objFolder = Nothing
'
Set objFolder = objShell.NameSpace("N:\APPS" )
if not objFolder is nothing then  
 for each item in args   
  objFolder.CopyHere item, 16  
 next  
End If
Set objFolder = Nothing
'
Set objFolder = objShell.NameSpace("W:\APPS" )
if not objFolder is nothing then  
 for each item in args   
  objFolder.CopyHere item, 16  
 next  
End If
Set objFolder = Nothing
'
Set objFolder = objShell.NameSpace("X:\APPS" )
if not objFolder is nothing then  
 for each item in args   
  objFolder.CopyHere item, 16  
 next  
End If
Set objFolder = Nothing


Report •
Related Solutions


Ask Question