Solved

Get result

Posted on 2006-11-07
4
178 Views
Last Modified: 2010-05-03
I am using the following sections of code:

Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile("c:\*.bak")

and

fs.CopyFile "source.dat", "c:\backup.bak"


how can i get results from these commands to check that they have completed successfully or not?
0
Comment
Question by:xizor
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
JackOfPH earned 125 total points
ID: 17895364
Try to use on error...

On error Goto err1:
Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile("c:\*.bak")

msgbox("Delete Successful")
Exit sub

err:
msgbox("delete not successful")
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17895373
or

On error Goto err1:

fs.CopyFile "source.dat", "c:\backup.bak"
msgbox("Copy Successful")
Exit sub

err:
msgbox("Copy not successful")
0
 
LVL 2

Author Comment

by:xizor
ID: 17895424
I'm already using an on error for the procedure, i was wondering if there was anyway to get a result from these particular commands.

For example, I am not using force delete opn read only files, so when i made a file read only, it doesn't get deleted, but it doesn't get picked up as an error either.
0
 
LVL 2

Author Comment

by:xizor
ID: 17895506
oh...ignore that....

I dont know why, but when i first tested it i got no error....

then trying some other stuff.. it came back... permission denied...

thanks
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 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