雖然有很多第三方程式可以完成一項任務,但有時您只想使用內建方法來完成同樣的任務。今天的超級使用者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使用者那裡瞭解更多答案嗎?在這裡檢視完整的討論主題。
...對某些人來說,XP是無法戰勝的。因此,我們將向您展示如何在Windows10上恢復WindowsXP。 ...
...從頭開始要好得多。讓我們看看這些恢復方法,看看它是如何做到的! ...
...2018年。你今年有什麼新年決心?希望其中之一是在你的Windows作業系統上嘗試一些新的應用程式。如果你真的下了決心,你就來對地方了。 ...
想學習如何強制關閉程式嗎?本文介紹了最好的Windows程式**,從最簡單的到最有效的。 ...
... 在本文中,我將向您展示如何使用FAT/FAT32格式化大型硬碟驅動器,或者如何使用該檔案系統建立一個32+GB的分割槽。 ...
... IOActive實驗室的一位研究人員對微軟如何允許安裝mod很感興趣。過去,從微軟商店下載的遊戲往往是在沙盒環境中執行的,因此使用者必須透過額外的限制才能在遊戲中執行mod。微軟是如何讓這個過程如此簡...
...果預設情況下會隱藏庫資料夾,因此很難找到它。下面是如何找到它。 小心你的圖書館資料夾 蘋果隱藏Library資料夾有一個很好的理由:它包含macOS和應用程式的基本配置檔案。如果不小心刪除或修改了這些檔案,可能會導致...
...人照片和影片真的保持隱私,我們有一些更好的提示。 如何在照片應用程式中隱藏照片和影片 當你在iPhone或iPad上拍攝照片時,它會和其他照片一起出現在你的照片庫中。如果你經常用**炫耀你可愛的貓的照片,那麼你可能會...
...特定內容發生意外或有意更改的一種很好的方法。下面是如何在Word中鎖定文字框。 鎖定word中的文字框 假設您正在處理同一網路上的其他人可以訪問的文件,並且您希望鎖定文字框,這樣它們就不會被錯誤地編輯。 相關:如...