<p>Imagine we have a program trying to write to a particular file, but failing.</p>
<p>On the Windows platform, what are the possible things which might be causing the file to be un-writable, and what steps could be suggested to an end user/administrator to fix it.</p>
<hr />
<p>Please include steps which might require administrator permissions (obviously users may not be administrators, but for this question, let's assume they are (or can become) administrators.</p>
<p>Also, I'm not really familiar with how permissions are calculated in windows. - Does the user need write access to each directory up the tree, or anything similar to that?</p>

[{'answer_id': 37527, 'author': 'Michael Ratanapintha', 'author_id': 1879, 'author_profile': 'https://Stackoverflow.com/users/1879', 'pm_score': 3, 'selected': True, 'text': '<p>Some suggestions:</p>\n\n<ul>\n<li>No write permission (get permission through Security tab on file Properties window; you must be the file owner or an Administrator)</li>\n<li>File is locked (close any program that may have the file open, then reboot if that doesn\'t help)</li>\n<li>File has the read-only DOS attribute set (unset it from file Properties window, or with <code>attrib -r</code>; you must be the file owner or an Administrator)</li>\n</ul>\n\n<p>Edit 1: Only the second item (file is locked) has a possible solution that all users are likely to be able to do without help.  For the first and third, you\'ll probably want to provide guidance (and hope the file wasn\'t made read-only intentionally!).</p>\n\n<p>Edit 2: Technically, the user does need write and execute (chdir) permissions on all directories up to the root.  Windows may skip some of the recursive checks up the tree as a performance optimization, but you should not rely on this because admins can force on these so-called "traverse checks" for certain users.</p>\n\n<p>Edit 3: @RobM: Yes, you should check that there is no obvious reason that the user should not have the permissions she needs but does not have.  I alluded to this in a less direct way in my first edit.  However, in some cases users should have write permission to a file but do not because of filesystem corruption, a misbehaving program, or a mistake on their own part.</p>\n'}, {'answer_id': 37546, 'author': 'Sean Kearon', 'author_id': 2608, 'author_profile': 'https://Stackoverflow.com/users/2608', 'pm_score': 1, 'selected': False, 'text': '<p>If you are having trouble working out if the file is locked, try using <a href="http://www.emptyloop.com/unlocker/" rel="nofollow noreferrer">Unlocker</a> - it\'s a really useful free utility that shows you the process that has locked the file and lets you force an unlock if you need to.</p>\n'}, {'answer_id': 37661, 'author': 'Sam Hasler', 'author_id': 2541, 'author_profile': 'https://Stackoverflow.com/users/2541', 'pm_score': 0, 'selected': False, 'text': '<p>On Vista could it also be that it\'s "marked" as unsafe because it\'s been downloaded from the internet and you have to click the unblock button on it\'s explorer properties dialog?</p>\n'}, {'answer_id': 37712, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>Lets change this around a bit. If your program is trying to write to a file and failing you either need to change the location of the file to one where the user can write to, or check the correct rights when the program starts and refuse to run if the user doesn't have them. Trampling over the system permissions is not the answer.</p>\n"}]
['https://Stackoverflow.com/questions/37525', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/797/']