Odd AccessControl error
I'm using the AccessControl plugin to set the rights on a data directory set up by my installer. The directory is freshly-created and known to exist, so the user running install will be its "CREATOR OWNER" and should have authority to set the access.
However, I'm occasionally -- not always, but I haven't spotted a trend -- getting error "22" returned. Looking at the source for the plugin I see that errors are usually textual, and that "22" doesn't seem to be one of them!
Here's the code snippet:
; create the data directory
ClearErrors
CreateDirectory "$MBDir"
${If} ${Errors}
Abort "Can't create MessageBase directory $MBDir"
${EndIf}
; Set access permissions on $MBDir -- read write accessible by all users
; We have to use "(S-1-1-0)" instead of "World" or "(WD)" for Win2k
ClearErrors
AccessControl::GrantOnFile "$MBDir" "(S-1-1-0)" "GenericRead + GenericWrite + DeleteChild"
pop $0
${If} $0 != ""
MessageBox MB_OK "Error $0 granting access to $MBDir "
${EndIf}
The message I'm getting in the message box is typically something like "Error 22 granting access to E:\MyApp\Data ". The directory name is correct, and the directory has been created.
Can anyone tell me what this actually means? I take it I am calling the plugin correctly, and that GrantOnFile is meant to be usable on directories as well as normal files?
The Windows error code 22 is ERROR_BAD_COMMAND which is documented as meaning "The device does not recognize the command". I believe that's normally returned by IOCtl-type calls to devices, and not by access control APIs.
I'm testing this on XP64, BTW, but it's intended to be usable on all NT-class systems.