虽然有很多第三方程序可以完成一项任务,但有时您只想使用内置方法来完成同样的任务。今天的超级用户Q&A帖子帮助读者找到一个很棒的内置解决方案,防止他的文件被删除或覆盖。
今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。
记事本截图由丹(超级用户)提供。
超级用户读者boboes想知道在Windows 7和更新版本中是否有一个内置方法来锁定文件并防止其被覆盖或删除:
Is there a way to lock a file with in-house means so that it cannot be deleted or overwritten? I need to temporarily lock files while testing copy scripts in order to check the error handling in those scripts. Until Windows XP, I would load a file in debug.exe to lock it. Is there a way to do this in Windows 7 and newer editi***?
I know that there are programs for doing this. My question is if there is a built in mechani** in Windows 7 and newer editi***. Sometimes I have to check a script on a PC and do not want to install new programs for that.
There are also some good suggesti*** here: How to purposefully exclusively lock a file? Unfortunately, they require 3rd party tools or changing the file to a locked state.
在Windows7和更新版本中是否有内置的方法来执行此操作?
超级用户贡献者丹和突破为我们提供了答案。首先,丹:
I think PowerShell is probably the neatest way to accomplish this. Something like the following:
While paused, the above script causes the following prompt when attempting to open up “myfile.txt”:
接着是突破的答案:
For the curious, here is the MSDN link to the File::Open method detailing the parameters of the call (specifically, the last argument ‘None’, declines sharing the file with any other threads/processes). Likewise, provisi*** exist to lock the file for read/write only, or a combination thereof.
有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。
...2018年。你今年有什么新年决心?希望其中之一是在你的Windows操作系统上尝试一些新的应用程序。如果你真的下了决心,你就来对地方了。 ...
...个逐步删除大量恶意软件的方法。此外,我们将向您展示如何阻止恶意软件感染您的系统,首先。如果你不必担心恶意软件,你将有更多的时间在生活中更好的事情。 ...
...视为一个名为Windows的文件夹中的文件。你可以想象这将如何引起混乱,所以计算机根本不允许。 ...
... 尽管如此,您可能仍然想知道如何禁用Internet Explorer(IE)。也许你不想让系统中的其他用户在笨重的浏览器中工作,或者只是讨厌它并想从你的系统中阻止Internet Explorer。 ...
你在你的电脑上运行Linux,但你也安装了Windows。这是一个双引导,但有时您希望在两个操作系统之间共享数据。 ...
...其中之一是Windows10上的WindowsDefender内置的新功能。下面是如何使用它。 ...
...描您的电脑上的恶意软件,并删除任何您发现的。以下是如何清除你的电脑病毒和恶意软件。 虽然许多病毒和其他类型的恶意软件的设计只是为了引起混乱,但越来越多的恶意软件是由有组织犯罪**的,目的是窃取信用卡号码、...