为什么mkdir偶尔会拒绝访问? [英] Why does mkdir occasionally give Access Denied?
问题描述
我有BAT脚本,没有什么棘手,在XP上工作正常。但在Win 7,mkdir下面的rmdir的5个执行中约有1个给了一个神秘的访问被拒绝。例如
S:\TLIB importing\! Curtains \2处理> rmdir temp3allout / s / q
S:\TLIB importing\! Curtains \2处理> mkdir temp3allout
访问被拒绝。
在这之后,当我在Explorer中尝试时,使用该目录没有问题。
Win XP光盘是一个常规的2Gb光盘驾驶。 Win 7光盘是一个2Gb Intel RST RAID1阵列,已禁用缓存和刷新功能 http://i.imgur.com/
当文件系统尚未完成删除目录时,会发生这种情况。
有时,这会同步发生,即在rmdir命令完成之前,但有时会有非常短但非零的延迟。 (在XP中它总是同步的,IIRC。)
如果可能,避免删除并立即重新创建目录;如果你不能避免它,你需要检测失败并重试。
你可能还需要测试,如果需要重试rmdir;有时rmdir遇到相同的问题,无法删除整个目录树。
I have BAT scripts which are nothing tricky and work fine on XP. But on Win 7, about 1 in 5 executions of mkdir following rmdir give a mystery Access Denied. E.g.
S:\TLIB importing\! Curtains\2 To process>rmdir temp3allout /s /q
S:\TLIB importing\! Curtains\2 To process>mkdir temp3allout
Access is denied.
After this, when I try in Explorer, it has no problem making that directory. Running thatBAT again usually succeeds.
Any idea what's going on here?
Win XP disc was a regular 2Gb drive. Win 7 disc is a 2Gb Intel RST RAID1 array with caching and flushing disabled http://i.imgur.com/Ohqkg2t.png .
This happens when the file system hasn't finished deleting the directory yet.
Sometimes this will happen synchronously, i.e., before the rmdir command completes, but sometimes there will be a very short but nonzero delay. (In XP it was always synchronous, IIRC.)
If possible, avoid deleting and immediately recreating directories; if you can't avoid it, you'll need to detect the failure and retry.
You should probably also test and if necessary retry the rmdir; sometimes rmdir runs into the same problem and fails to delete the entire directory tree.
这篇关于为什么mkdir偶尔会拒绝访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!