博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
windows锁定文件夹_如何在Windows中锁定文件以阻止删除或覆盖?
阅读量:2508 次
发布时间:2019-05-11

本文共 2875 字,大约阅读时间需要 9 分钟。

windows锁定文件夹

windows锁定文件夹

how-do-you-lock-a-file-in-windows-to-block-overwriting-or-deletion-00

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 .

记事本屏幕截图由 。

问题 (The Question)

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和更高版本中是否有内置方法可以执行此操作?

答案 (The Answer)

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可能是完成此任务的最简洁的方法。 类似于以下内容:

how-do-you-lock-a-file-in-windows-to-block-overwriting-or-deletion-01

While paused, the above script causes the following prompt when attempting to open up “myfile.txt”:

暂停时,以上脚本在尝试打开“ myfile.txt”时引起以下提示:

how-do-you-lock-a-file-in-windows-to-block-overwriting-or-deletion-02

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/

你可能感兴趣的文章
表达式求值-201308081712.txt
查看>>
centos中安装tomcat6
查看>>
从Vue.js窥探前端行业
查看>>
学习进度
查看>>
poj3368 RMQ
查看>>
“此人不存在”
查看>>
github.com加速节点
查看>>
解密zend-PHP凤凰源码程序
查看>>
python3 序列分片记录
查看>>
Atitit.git的存储结构and 追踪
查看>>
atitit 读书与获取知识资料的attilax的总结.docx
查看>>
B站 React教程笔记day2(3)React-Redux
查看>>
找了一个api管理工具
查看>>
Part 2 - Fundamentals(4-10)
查看>>
使用Postmark测试后端存储性能
查看>>
NSTextView 文字链接的定制化
查看>>
第五天站立会议内容
查看>>
CentOs7安装rabbitmq
查看>>
(转))iOS App上架AppStore 会遇到的坑
查看>>
解决vmware与主机无法连通的问题
查看>>