8
2
I seem to have a general problem with "access denied on Windows". It manifests itself every time if e.g:
- My bat file calls a compiler creates a file on disk
- My bat file renames a file
- But I also have files downloaded (FireFox) to Windows desktop where Windows is giving me "access denied" if I try delete the file.
- Tried disable AVG + make exception in AVG resident shield
(I have tried checking with Task Manager + Winternals process explorer that it is not process running still running that should cause the locks.)
- Windows 7.
- My user account is an administrator.
- All files are created by same user account.
The problem is recent, but some things I first noticed yesterday (when I started calling .bat files again which I have used for many years)
I have tried:
- Starting e.g. Windows Explorer with "run as administrator", but that makes no difference
- right-click - properties - security and changes permissions/ownership (I also get "access denied" when trying this so this does not help)
Here is a ascreenshot if I try change security of a "locked" file. (The problem here is the locking occurs continously every time the file is created)
!
If I click onwards, it states I am not the owner? Instead I see this: "Unable to display current owner"
If I try to change ownership, I get "access denied" (don't have rights)
Which baffles me as I just created it. (Yes, through a .bat file calling executables that create the file. But all running under my administrator user account.)
I think this is some kind of weird issue of something somewhere holding file handles for some time after file has been attempted deleted by .bat file...
I have tried to walk away 5 minutes after the .bat file has issue the delete instruction. (Pausing .bat script) When returning (after minutes) the file is gone. (This took some time for me to notice since it was by accident I discovered this, but it seems I can repeat it)
So the reason for all the problems may be the file somehow is in a kind mysterious state where the file has been scheduled for deletion, but it just goes extremely slow? (And hence all other operations performed on the file also behaves very oddly.)
I have no idea why this is (have tried disabling e.g. AVG), but I guess it could explain the sudden problems?
Can you check the effective permissions for your user on a directory you don't have access? – None – 2012-10-26T14:35:40.270
The problem occurs on specific files. Files that are somehow created through applications called by my .bat file (Does not help being an administrator account + starting the .bat file with "run as administrator.) I have just uploaded a screenshot showing the dialog I get when trying to edit security for a locked file. (Normally for all the other non-locked files, I am shown the normal security dialog. But with the locked, I get "access denied" to even edit security.) – Tom – 2012-10-26T15:50:05.410
1Can you check the permissions on your batch file? – None – 2012-10-26T17:20:34.763
Verified Users (Translated from Danish): Modify, Read&Execute + Read + Write. System + Admins: Full Control, Modify, Read&Execute + Read + Write. Users: Read + Read&Execute – Tom – 2012-10-26T17:44:31.277
1Files inherit the permissions of the parent folder when they are created, maybe check the permissions of the parent folder? – David – 2012-10-26T17:55:19.250
For all folders wherein files are created / bat file run from etc: Verified Users + System + Admins: Full Control, Modify, Read&Execute + Read + Write + ListFolderContent. Users Read + Read&Execute + ListFolderContent – Tom – 2012-10-26T18:03:00.610
You say you have problems when your BAT file creates/manipulates files. What happens if you execute the same commands directly at the Command Prompt (i.e., copy from the BAT file and paste into Command Prompt)? – Scott – 2012-10-26T21:37:40.040
1I notice that your pathname begins with
W:
, i.e., it is on a network share. Do you get the same problems on theC:
drive? Is there any possibility that the file server doesn’t fully recognize your credentials? This might happen if you are an ordinary user on the domain, and Administrator only on your local machine. – Scott – 2012-10-26T21:38:31.707W: is a partition on a local disk (W = work). However, during my continued testing yesterday, I found the reason may be slightly different than what I first assumed. It appears the delete instructions given in the .bat file are delayed by minutes. (i.e. from the delete instruction is given, the delete is first done after e.g. 3-4-5 minutes. And meanwhile any operations on the file give access denied errors.) I have zero idea about what is going on since deleting files normally is instantaneous. And I have tried disabled AVG... So... No idea... :( Updated initial description/question at bottom – Tom – 2012-10-27T14:48:04.770
Just for reference, this is still a problem. After the delete instruction is given, it can sometimes take up to 10 minutes before the file actually is removed (if watching wih e.g. Windows Explorer), and until then all operations on the file are denied. (Beyond thad, there are also other slightly funky file access errors in my system. (I don't know if related or not. But if I download files to desktop using e.g. FireFox, I am told it does dot have access rights tto place the file there.) I suspect this whole thing may be associated to some Windows (security?) registry settings. – Tom – 2013-02-05T07:57:29.810
1@Tom: I recommend running a disk check (right-click the volume in My Computer and choose Properties->Tools->Error-checking->Check now... as it sounds as though your file system could be corrupt. – James P – 2013-02-05T10:06:26.837
Already tried buying and using a new disk. Problem persist :( (That said, I will of course ry run a disk check later today and report, just in case) – Tom – 2013-02-05T10:47:11.247
If you have multiple disks/partitions you might want to run it on all of them. – James P – 2013-02-05T11:49:14.447
1Which file are you trying to delete that it is hanging on, is it
{YourAppName}.vshost.{YourAppExtension}
(ex:SampleApp.vshost.exe
) by any chance? – Scott Chamberlain – 2013-02-05T16:32:57.930Can you post some syntax from your batch file so we know what is going on? – BroScience – 2013-02-05T21:43:14.600
@ScottChamberlain It is execuables (example.exe) but they are not running anywhere any longer (neither the program that created them, nor themselves) if e.g. checking Windows task manager. – Tom – 2013-02-06T10:25:16.977
@BroScience It is a simple: del "%V_Disk_Org_CompiledExeImmediate%" . As the original post states, the deletion does come through... If you wait like 5-10 minnutes. All subsequent actions on the file (while waiting for the "del" to come through) results in "access denied". – Tom – 2013-02-06T10:27:18.363
1@Tom: did you try the disk check? If that doesn't help I would suggest you try Safe Mode to determine if a program is responsible. – James P – 2013-02-08T21:56:25.420
@James No luck. (But it would also be odd since the disk is very new + the problem was also there on the old disk.) – Tom – 2013-02-11T01:00:03.373
@James I guess safe mode is worth trying. Will do. (Just ran chkdsk again and no problem reported of any kind on disk/partitions) – Tom – 2013-02-12T15:14:18.730