Search code examples
windowsfile-permissionsfile-access

How to protect a file in Windows


Update 3: the restrict access, using the security tab works now. (that's manually) now looking to do it programatically (using Visual C#) and also how to access a file using administrator account in a simple user account. hint - I noticed this feature in Windows, right click and use 'Execute as', enter the administrator password and then you can access the file.

Update 2: Found how to display the security tab

To display the Security tab

Open Folder Options in Control Panel. (Click Start, click Control Panel, click Appearance and Themes, and then click Folder Options.)

On the View tab, under Advanced settings, clear Use simple file sharing [Recommended].

Update 1: I found the following article, which suggests how to give permissions to files, however I don't find the security tab when I click properties, do you have it? Any ideas how to get it

I have a file that I want to protect from bein modified. Don't say to me encrypt it, this don't solve the problem, I want that users can't change the file, BUT only me (my program). Is there any type of authentication for Windows files, I know that what I say is stupid about authentication, but some Windows files are inaccessible like 'ntuser.dat.LOG' in the user profile. When I try to open this file it doesn't open.

I want something like that, for this file it seems because Windows is using it. Right. But what about if my program shutdown, I don't want the file to be changed in this case also. How shall i do?

I don't ask for the complete detailed solution, I want ideas, suggestions, tips, or any thing you know that it'll help, as it seems to be complicated :p


Solution

  • Are you on a Windows domain, or just a workgroup? What version of Windows is this? Are you an administrator of the computer?

    You should be able to take ownership of a file, and then set the permissions so that you're the only one that can access that file. On Windows XP (Vista is similar) Right-click on the file and view Properties. Select the Security tab and then you can set specific permissions on a file. You can click Advanced and set even more specific options.

    If you're on a domain, the domain administrators will always be able to view/edit any of your files.

    Edit: From KB 290403:

    In Windows XP Home Edition and Windows XP Professional, if working in a workgroup, the Security tab is hidden by default. This behavior occurs because in Windows XP Home Edition and Windows XP Professional, guests are forced to log on to a workgroup.

    So if you want to pursue this, you can boot your computer into Safe mode and then you'll see the Security tab.

    You can also uncheck Simple file sharing in the Advanced options.