Hello everyone,
I seem to have hit an undocumented security precaution only found in Windows XP SP3, and I want to make sure that I’m not mistaken and perhaps some other factor is to blame.
I have an EXE that calls SHFileOperation to perform a recursive file copy (yes, I’m lazy, best code is the least code, and so on and so forth) from the same directory to the local system drive.
The call to SHFileOperation works fine if the EXE is run from the local disk, but fails only if the EXE is on the USB disk, with ERROR_CANCELLED.
However, if I remove the FOF_SILENT from the call to SHFileOperation, the call succeeds regardless of where the EXE is being run from. I can’t find any reference to this anywhere, but it does seem like it could be a security “improvement” in SP3. Note that all code is being run as an administrator (it’s a setup) and so it’s not a permissions issue.
IF it is a security thing, I don’t see the benefit - any coder worth his salt can write a recursive file copy using core WIN32 APIs. But I don’t see any other reason an invisible write would fail, while a user-visible write would succeed. So color me confused.
Has anyone come across this issue before and is there any way other than (a) writing a recursive FileCopy function, or (b) launching said exe with SW_HIDE to get around this anyway? And if this indeed an attempt at security, does any have idea why MS would do something this futile and pointless, hindering only well-meaning developers?
(FYI The code runs fine on Vista and 7 as an administrator with elevated UAC privileges.)