Running the above code with a large numer of files (about 600MB in my test), NSIS cannot catch the event if the user clicks "Cancel" button quickly after the copying dialog appears. If the user clicks the "Cancel" button after a few minutes, NSIS can successfully catch the event and popup the message box.ClearErrors
CopyFiles C:\dir1\*.* C:\dir2
IfErrors 0 +2
MessageBox MB_OK "Error or cancelled!"
The problem seems related to the not-very-short preparation stage of the long copying operation. Is it a bug of NSIS or Windows? Any solution?