Windows XP 上的不可移动文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52172/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:09:50  来源:igfitidea点击:

Unmovable Files on Windows XP

windowsfilesystems

提问by Terry

When I defragment my XP machine I notice that there is a block of "Unmovable Files". Is there a file attribute I can use to make my own files unmovable?

当我对 XP 机器进行碎片整理时,我注意到有一个“不可移动文件”块。是否有文件属性可用于使我自己的文件不可移动?

Just to clarify, I want a way to programmatically tell Windows that a file that I create should be unmovable. Is this possible, and if so, how can I do it?

只是为了澄清,我想要一种方法来以编程方式告诉 Windows 我创建的文件应该是不可移动的。这可能吗,如果可以,我该怎么做?

Thanks,

谢谢,

Terry

特里

回答by JosephStyons

A lot of system files cannot be moved after the system boots, such as the page file and registry database files.

很多系统文件在系统启动后无法移动,例如页面文件和注册表数据库文件。

This utilityruns before Windows boots to defragment those files. I have it set to run at every boot, and it works well for me on several machines.

此实用程序在 Windows 启动之前运行以对这些文件进行碎片整理。我将它设置为在每次启动时运行,它在多台机器上运行良好。

Note that the very first time you boot up with this utility set to run, it may take several minutes to defrag. After that first run though, it finishes in just 3 or 4 seconds.

请注意,第一次启动时将此实用程序设置为运行,可能需要几分钟的时间进行碎片整理。但是,在第一次运行之后,它会在 3 或 4 秒内完成。

Edit0: To respond to your clarification- that link says windows has marked the page file and registry files as open for exclusive access. So you should be able to do the same thing with the LockFileAPI Call. However, that's not an attribute of the file itself. You'd have to actually run some background program that locks the file for exclusive access.

Edit0:为了回应您的澄清 - 该链接表示 Windows 已将页面文件和注册表文件标记为打开以供独占访问。所以你应该能够用LockFileAPI 调用做同样的事情。但是,这不是文件本身的属性。您实际上必须运行一些后台程序来锁定文件以进行独占访问。

回答by Mark

There are no file attributes that you can place on your files to mark them as immovable. The only way that a file cannot be moved (I think) during defragmentation is to have some other process have the file open (for read or write, I'm not even sure that you need to have the file open in exclusive mode or not).

没有文件属性可以放置在文件上以将它们标记为不可移动。在碎片整理期间无法移动文件(我认为)的唯一方法是让其他进程打开文件(对于读取或写入,我什至不确定您是否需要以独占模式打开文件)。

Quite frankly, I cannot think of a reason that you'd want your files not to move, unless you have specific requirements about where on the disk platter your files reside. Defragmentation should generally lead to faster disk access and that seems to be desireable in all cases :-)

坦率地说,我想不出您希望文件不移动的原因,除非您对文件所在磁盘盘片的位置有特定要求。碎片整理通常会导致更快的磁盘访问,这似乎在所有情况下都是可取的:-)

回答by Pat

I suppose the ugly way is to have an application boot on startup, check every few seconds if defrag is running and if so open the file in exclusive mode.

我想丑陋的方法是在启动时启动应用程序,每隔几秒钟检查一次碎片整理是否正在运行,如果是,则以独占模式打开文件。

This is really ugly and I don't recommend it unless there is no cleaner solution.

这真的很难看,除非没有更清洁的解决方案,否则我不推荐它。

回答by Chris Driver

Terry, the answers all mention ways to prevent files from becoming unmovable during defragmentation. From your question it appears that you are in fact wanting to makeyour personal files unmovable. Can you please clarify what is appealing about making your files unmovable.

特里,答案都提到了防止文件在碎片整理过程中变得不可移动的方法。从您的问题看来,您实际上是想让您的个人文件不可移动。您能否澄清一下使您的文件不可移动的吸引人之处。

回答by TheSmurf

This usually means that the file is in use by some process. If you're defragmenting, you'll likely see this with a lot of system files. If the file should legitimately be movable and is stuck (it's being held by a process that runs at startup but shouldn't be, for example), the most useful way of resolving the problem is to remove all permissions on the file, reboot, restore the permissions, and then get rid of the file/run the program that's trying to use it.

这通常意味着该文件正在被某个进程使用。如果您正在整理碎片,您可能会在大量系统文件中看到这一点。如果文件应该合法地可移动并且被卡住(例如,它被一个在启动时运行但不应该被卡住的进程所持有),解决问题的最有用的方法是删除文件的所有权限,重新启动,恢复权限,然后删除文件/运行试图使用它的程序。

回答by ddowns

For a little more complete solution try Raxco's PerfectDisk. While it is a commercial product it does a very good job and supports boot time defrag of system files. The first defrag takes longer than say DiskKeeper but its a single pass defragger and supports defragging with very little free space left on the drive. Overall its a much smarter defrag program then any other I've seen and supports systems of any size.

如需更完整的解决方案,请尝试 Raxco 的 PerfectDisk。虽然它是一种商业产品,但它做得非常好,并且支持系统文件的启动时碎片整理。第一次碎片整理需要比 DiskKeeper 更长的时间,但它是一个单程碎片整理程序,并支持在驱动器上剩余很少可用空间的情况下进行碎片整理。总的来说,它是一个比我见过的任何其他程序更智能的碎片整理程序,并支持任何规模的系统。

http://www.raxco.com/

http://www.raxco.com/

回答by Galvion

first try to move(or delete) the files within safe mode. If can not, try to move(or delete) the files with linux.

首先尝试在安全模式下移动(或删除)文件。如果不能,请尝试使用 linux 移动(或删除)文件。

But be careful if those are the windows system files, then you are failed to boot up your windows.

但是要小心,如果这些是windows系统文件,那么你将无法启动你的windows。

Some reason why the files are unmovable are : the file size is too big, the files are being in open/in use condition, insufficient security privileges, being access by other computer/s, and many other things.

文件不可移动的一些原因是:文件太大,文件处于打开/使用状态,安全权限不足,被其他计算机访问等等。

回答by Abdu

I assume you're using the defragger that comes with Windows. Some commercial ones like DiskKeeper can move some of these files (usually system files). You can try their trial versions.

我假设您使用的是 Windows 附带的碎片整理程序。一些像 DiskKeeper 这样的商业文件可以移动其中的一些文件(通常是系统文件)。你可以试试他们的试用版。

回答by Abdu

Contig might serve your purpose http://technet.microsoft.com/en-us/sysinternals/bb897428.aspx

Contig 可能为您服务http://technet.microsoft.com/en-us/sysinternals/bb897428.aspx

I'm relatively certain I ran across some methods/attributes you could access programatically to do exactly what you want. This was back in NT4 days though and my memory isn't that good.

我相对确定我遇到了一些您可以通过编程访问的方法/属性,以完全按照您的意愿执行操作。不过这已经是 NT4 天了,我的记忆力不是那么好。