Днешната сесия за въпроси и отговори ни идва с любезното съдействие на SuperUser - подразделение на Stack Exchange - обединяване на уеб сайтове с въпроси и отговори.
Бележник на екрана, предоставен от Dan (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?
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.
There are also some good suggestions here: How to purposefully exclusively lock a file? Unfortunately, they require 3rd party tools or changing the file to a locked state.
Има ли вграден метод за това в Windows 7 и по-нови издания?
Отговорът
Сътрудниците на SuperUser Дан и Пробив имат отговора за нас. Първо, Дан:
I think PowerShell is probably the neatest way to accomplish this. Something like the following:
Следва отговор от пробив:
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, provisions exist to lock the file for read/write only, or a combination thereof.
Имате ли нещо, което да добавите към обяснението? Звучи в коментарите. Искате ли да прочетете повече отговори от други потребители на Stack Exchange? Вижте цялата тема на дискусията тук.