BleepingComputer.com: Missing Flash Drive Aborts VBScript Copying

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Missing Flash Drive Aborts VBScript Copying

#1 User is offline   steve.marks59 

  • New Member
  • Pip
  • Find Topics
  • Group: Members
  • Posts: 11
  • Joined: 23-May 10

Posted 07 December 2010 - 09:42 PM

My OS: XP-PRO SP3

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

#2 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 08 December 2010 - 08:27 AM

Try this:
http://www.devguru.com/technologies/vbscript/quickref/filesystemobject_driveexists.html
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#3 User is offline   steve.marks59 

  • New Member
  • Pip
  • Find Topics
  • Group: Members
  • Posts: 11
  • Joined: 23-May 10

Posted 08 December 2010 - 01:17 PM

My Problem was solved on another forum.
Here is the link:
My link

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



Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users