MoveFileEx("c:\windows\temp\tempfile.tmp", "C:\Windows
\SYSTEM32\example.exe", MOVEFILE_DELAY_UNTIL_REBOOT |
MOVEFILE_REPLACE_EXISTING)
to self update working NT service during reboot.
File is moved properly but access rights on destination file is
broken. It seems that all inherited permissions are not updated during
rename operation. If you run cacls or look into security settings of C:
\Windows\SYSTEM32\example.exe you can see that every inherited ACE is
referring to old folder "c:\windows\temp\" not "C:\Windows\SYSTEM32\".
And result is that all common users (not administrators) have no right
to read or execute example.exe which break our application (it works
in two modes service and common user application). This behavior can
be observed for any folder. I see no explanation in MSDN.
Can anyone share good strategy to solve this issue?
I tested it on Windows XP Prof SP2.
Place it in the destination folder with a different name, instead of
placing it in the temp folder.
MoveFileEx will then rename the file only and the permissions are
correct.
---
Stefan Pendl
Windows XP Pro SP 3
Celeron M 1.3 GHz
752 MB DDR RAM