Re: xcopy and vbscript



On Jun 6, 5:33 pm, mr_unreliable <kindlyReplyToNewsgr...@xxxxxxxxxxx>
wrote:
hi Sharpshooter,

Yes, fso is slow, and in certain circles (the winapi ng
for example) it is considered to be beneath comtempt.
However, it is a tried-and-true tool for scripters.

If you want a "faster" then you could try the
"shell.application" copyhere method. A demo script is
attached. Also, copyhere has some side benefits. It
will show the same copy dialog as the system uses.
(note that you will only see the dialog if the copy
takes some time. If the copy goes very quickly, you
won't see the dialog).

And yes, xcopy is also faster than fso.

One final thought. Strange as it may seem, not all
flash drives run at the same speed (gasp!) -- at least
on my system. For example, the sony drive has compression,
which may be good news or bad news. Good news if you want
more capacity. Bad news if you want speed, because there
is a noticeable delay in reading and writing to it.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)



shrpshtr wrote:
With the help of some great folks here, I am running a vb script to
backup a user's files to a usb drive. It is working beautifully with
one minor problem. It takes about 5-6 minutes to backup approximately
200-300mb. Will xcopy reduce the time it takes to copy the data over
to the usb drive? A copy of the script is below for reference.
Thanks in advance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strFolderName)

Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\documents and settings\erobbins\my documents
\*.*" , strFolderName , OverwriteExisting

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\documents and settings\erobbins\my documents
\*.*" , strFolderName , OverwriteExisting

Set objFSO = CreateObject("Wscript.Shell")
strMessage = "Backup Complete. Click OK to Finish."
ObjShell.Popup strMessage, 5, "Backup Complete", OK_Button

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

shrp



[ShellCopyDemo.vbs.txt]' script to demo shell.application (for IE4/5 in win98)
Option Explicit
Dim oSHApp ' as object
Dim sSrc, sDest ' as string
Const FOF_SIMPLEPROGRESS = 256 '(&H100)

Set oSHApp = CreateObject("Shell.Application")

sSrc = "c:\windows\temp\*.*"
sDest = "A:\"

' use ms Animated Copy Applet, showing names and progressbar...
oSHApp.Namespace(sDest).CopyHere sSrc

' use ms Animated Copy Applet, showing progressbar (but no names)...
oSHApp.Namespace(sDest).CopyHere sSrc, FOF_SIMPLEPROGRESS

Set oSHApp = nothing ' clean up
WScript.Quit- Hide quoted text -

- Show quoted text -

thanks for the great response jw. the script demo works great and i
incorporated it into my existing script. it is a little faster. i
was wondering if xcopy would be any faster than this? if so, how
would that look. here is the merge between the demo you sent and my
original script. thanks in advance.


Set objShell = CreateObject("Wscript.Shell")
strMessage = "This script will Backup your files to the USB Drive.
Please click OK to continue..."
objShell.Popup strMessage, 10, "Backup Script", OK_BUTTON

strMonth = Month(Date)
If Len(strMonth) = 1 Then
strMonth = "0" & strMonth
End If

strDay = Day(Date)
If Len(strDay) = 1 Then
strDay = "0" & strDay
End If

strYear = Year(Date)
strFolderName = "f:\backup_" & strMonth & "." & strDay & "." & strYear

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strFolderName)

Dim objSHapp
Dim strSource ' , strDest
Const FOF_SIMPLEPROGRESS = 256
Const OVERWRITEEXISTING = True

Set objSHapp = CreateObject ("Shell.Application")

strSource = "C:\documents and settings\rafowler\my documents\*.*"


objSHapp.NameSpace(strFolderName).CopyHere strSource ,
OVERWRITEEXISTING

Set objFSO = CreateObject("Wscript.Shell")
strMessage = "Backup Complete. Click OK to Finish."
ObjShell.Popup strMessage, 5, "Backup Complete", OK_Button

WScript.Quit


.