Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Iam having a problem with denying current user from deleting file on desktop.
I tried to use icacls with:

icacls file /grant:r %username%:(X,AD,WD,RD) 

from site but it didnt help
I tried to deny only delete permission but it also didnt help.
Is there anyway to make desktop files undeletable but accessable using Shell or C++? I mean I like to be able to move icon around desktop but I want to make icon not able to delete or move to another folder. Iam using Windows xp and I need to make it under Windows xp.

share|improve this question

migrated from stackoverflow.com Nov 29 '11 at 15:03

This question came from our site for professional and enthusiast programmers.

1  
What OS is this? –  Chris Nov 29 '11 at 14:55
    
@Chris: Windows XP. –  Blender Nov 29 '11 at 14:57
4  
What does this have to do with C++ ? –  Paul R Nov 29 '11 at 14:57
1  
Also, wouldn't a user absolutely hate it when an application makes undeletable files? –  Ethan Steinberg Nov 29 '11 at 15:03
    
icacls didn't exist until Windows Vista. You need to use cacls instead, or the GUI. –  Harry Johnston Nov 30 '11 at 2:49

2 Answers 2

Your syntax is wrong. You are granting permissions, but you have to deny them.

Try:

icacls file /deny %username%:D

Complete syntax: Icacls

share|improve this answer
    
Dennis i already said that i tried this way. It didnt help also. It make file with none permission so icannot open it i cannot delete it and i cannot move it to another directory. This is not what i need, i need file to be undeleteable and accessable –  user107328 Nov 29 '11 at 15:45
    
You can't make a file undeleteable and movable! The very act of moving a file can force an OS to move the file from one disk to another. By definition, you are copying and deleting. What is your ultimate goal here? Perhaps you are using the wrong tools. –  surfasb Nov 29 '11 at 18:07
    
Ok so i like tomake file copyable but not deleteable. I just dont want to any1 delete my icons on desktop, but let them access to them(read and write). –  user107328 Nov 29 '11 at 18:29
    
surfasb thank you for solution but as I said before Iam using windows xp and I dont have here a tab called: security. I can import my actual c++ code to c# if it helps somehow. –  user107328 Nov 30 '11 at 2:02
    
@Jakub: If you are using XP Pro, you have to go under Explorer/ Tools/Options/View Tab, then turn off "Use Simple File Sharing" –  surfasb Dec 1 '11 at 6:14

Ok so i like tomake(sic) file copyable but not deleteable. I just dont want to any1 delete my icons on desktop, but let them access to them(read and write).

Now we are getting somewhere!

My first suggestion is to create a guest account, rather than giving users you may not trust access to your account. This is because they could just change your password, and thus you are SOL.

If your account is an Admin account and not a limited user, your final result is impossible. By definition, an Admin account has full permissions to any object on the system, either explicitly or implicitly through "Take ownership".

If you insist on this route:

To protect your icons on your desktop, you'll need to go into Explorer and click your user folder. Your desktop folder should be in there. For example, look under C:\users*username*\Desktop.

Right Click, then go to Properties/Security.

Click Advanced and uncheck "inherit permissions" and in the ensuing dialog box, press Copy. This will make a copy of the existing permissions.

Next click your account name and press Change permissions.

Turn off Delete files/folders, and take ownership permissions.

Press OK. Lastly, click a check mark in "apply to Child objects".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.