Kuidas blokeerite faili Windowsis blokeeringu kustutamiseks või ülekirjutamiseks?

Sisukord:

Kuidas blokeerite faili Windowsis blokeeringu kustutamiseks või ülekirjutamiseks?
Kuidas blokeerite faili Windowsis blokeeringu kustutamiseks või ülekirjutamiseks?

Video: Kuidas blokeerite faili Windowsis blokeeringu kustutamiseks või ülekirjutamiseks?

Video: Kuidas blokeerite faili Windowsis blokeeringu kustutamiseks või ülekirjutamiseks?
Video: TT: Closer to the Edge - TT3D - Subtiitrid saadaval! 2024, Aprill
Anonim
Kuigi ülesande täitmiseks on palju kolmanda osapoole programme, mõnikord soovid lihtsalt kasutada sama toimingu tegemiseks sisseehitatud meetodit. Tänane SuperUseri Q & A postitus aitab lugejal leida suurepärase sisseehitatud lahenduse, et oma faile kustutada või üle kirjutada.
Kuigi ülesande täitmiseks on palju kolmanda osapoole programme, mõnikord soovid lihtsalt kasutada sama toimingu tegemiseks sisseehitatud meetodit. Tänane SuperUseri Q & A postitus aitab lugejal leida suurepärase sisseehitatud lahenduse, et oma faile kustutada või üle kirjutada.

Tänane küsimuste ja vastuste seanss jõuab meile viisakalt SuperUserini - Stack Exchange'i ja kogukonnapõhiste Q & A veebisaitide rühmitusse.

Notepad ekraanipildi viisakus Dan (SuperUser).

Küsimus

SuperUser lugejaboboes soovib teada, kas faili lukustamiseks on Windows 7-s ja uuemates versioonides sisseehitatud meetod ja see ei tohi üle kirjutada ega kustutada:

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.

Kas sellel on sisseehitatud meetod Windows 7 ja uuemates versioonides?

Vastus

SuperUseri kaasautorid Dan ja läbimurre on meile vastuseks. Esiteks üles, Dan:

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”:
While paused, the above script causes the following prompt when attempting to open up “myfile.txt”:
Image
Image

Järgneb läbimurde vastus:

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.

Kas teil on seletamiseks midagi lisada? Helistage kommentaarides. Kas soovite lugeda rohkem vastuseid teistelt tech-savvy Stack Exchange'i kasutajatelt? Tutvu täieliku arutelu teemaga siit.

Soovitan: