Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Missing Flash Drive Aborts VBScript Copying


  • Please log in to reply
2 replies to this topic

#1 steve.marks59

steve.marks59

  • Members
  • 11 posts
  • OFFLINE
  •  
  • Local time:09:11 PM

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

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:11:11 PM

Posted 08 December 2010 - 08:27 AM

Try this:
http://www.devguru.com/technologies/vbscript/quickref/filesystemobject_driveexists.html

#3 steve.marks59

steve.marks59
  • Topic Starter

  • Members
  • 11 posts
  • OFFLINE
  •  
  • Local time:09:11 PM

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






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users