Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
experts:
i want to create file or delete file in system dir like c:\windows\winsxs, when i call create file or delete
file on win7 or win8, the last error is 5, and i have administrator priviledge. how can i do? thank you.
Posted
Comments
Sandeep Mewara 2-Mar-13 11:20am    
the last error is 5
Not clear.
cd_JoeWang 3-Mar-13 5:25am    
if you want to delete a file in vista/win7 system dir like c:\windows\winsxs\xxx.dat,
you must change the file's owner to administrator and add an allow ace with it.but i want to create or
delete file in system dir in my program by calling api like CreateFile or DeleteFile, but its return value
is 5, can not access. how can i do?
[no name] 2-Mar-13 11:25am    
You might have admin rights but that does not mean that whatever process you are using to create/delete files has admin rights.

1 solution

Error code 5 means ERROR_ACCESS_DENIED as described here[^]. You need to add a manifest to your project that requests administrator privilege for the program, or use the "Run as administrator" link in Windows Explorer when starting it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900