本文共 2875 字,大约阅读时间需要 9 分钟。
windows锁定文件夹
While there are plenty of third-party programs to accomplish a task, sometimes you just want to use a built-in method to do the same thing. Today’s SuperUser Q&A post helps a reader find an awesome built-in solution to keep his files from being deleted or overwritten.
尽管有很多第三方程序可以完成任务,但有时您只想使用内置方法来完成相同的任务。 今天的“超级用户”问答文章可帮助读者找到一个很棒的内置解决方案,以防止其文件被删除或覆盖。
Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.
今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。
Notepad screenshot courtesy of .
记事本屏幕截图由 。
SuperUser reader boboes wants to know if there is a built-in method in Windows 7 and newer editions to lock a file and keep it from being overwritten or deleted:
SuperUser阅读器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 editions?
有没有一种使用内部手段锁定文件的方法,以使它不能被删除或覆盖? 我需要在测试复制脚本时临时锁定文件,以检查这些脚本中的错误处理。 在Windows XP之前,我将在debug.exe中加载文件以将其锁定。 在Windows 7和更高版本中,有没有办法做到这一点?
I know that there are programs for doing this. My question is if there is a built in mechanism in Windows 7 and newer editions. Sometimes I have to check a script on a PC and do not want to install new programs for that.
我知道有执行此操作的程序。 我的问题是Windows 7和更高版本中是否存在内置机制。 有时我必须在PC上检查脚本,并且不想为此安装新程序。
There are also some good suggestions here: Unfortunately, they require 3rd party tools or changing the file to a locked state.
这里也有一些好的建议: 不幸的是,他们需要第三方工具或将文件更改为锁定状态。
Is there a built-in method for doing this in Windows 7 and newer editions?
在Windows 7和更高版本中是否有内置方法可以执行此操作?
SuperUser contributors Dan and Breakthrough have the answer for us. First up, Dan:
超级用户贡献者Dan和Breakthrough为我们找到了答案。 首先,丹:
I think PowerShell is probably the neatest way to accomplish this. Something like the following:
我认为PowerShell可能是完成此任务的最简洁的方法。 类似于以下内容:
While paused, the above script causes the following prompt when attempting to open up “myfile.txt”:
暂停时,以上脚本在尝试打开“ myfile.txt”时引起以下提示:
Followed by the answer from Breakthrough:
接下来是突破的答案:
For the curious, here is the detailing the parameters of the call (specifically, the last argument ‘None’, with any other threads/processes). Likewise, provisions exist to lock the file for read/write only, or a combination thereof.
出于好奇,这里是详细描述了调用的参数(特别是最后一个参数“ None” 与任何其他线程/进程 )。 同样,存在将文件锁定为仅读/写或其组合的措施。
Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? .
有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 。
翻译自:
windows锁定文件夹
转载地址:http://ybuwd.baihongyu.com/