how to check whether the xcopy command copied all the files or any error occured.Please help me it wouble be appreciated
i am using writeline function to write content in the bat file. can you please help me how do i use this here is my code
dim retval
for i=2 to 5
filepath = “C:\Windows\336.bat”
file.WriteLine “MkDir ” & folder
file.WriteLine “XCOPY ” & path & ” ” & folder & ” /SEY”
next
retval=shell(filepath)
i want to get the status of each copy statement
I dont know how to use the variable Errorlevel it shows some Type mismatch error
“file” and “path” are not assigned values in the code presented. That’s one problem.
Next, the return-code will be only that of the batch “wrapper”, not the individual operations initiated by it. The batchfile itself should handle the error reporting. Simplest method is to pipe error output of xcopy to a logfile:
file.WriteLine “XCOPY ” & path & ” ” & folder & ” /SEY 2>>xcerr.log”
but of course your batch could handle it other ways using errorlevel (from inside the batch, not your batch-creation code which is presenting problems anyway.)
So you are only using VBA to construct a batch file, and then you run the batch file? Well the link I gave gives you an example of what the batch file needs to look like. So you need to arrange for VBA to create a batch file that looks something like that one.