Share via


cipher

顯示或變更 NTFS 磁碟區上的目錄和檔案的加密。 如果沒有搭配參數使用,cipher 會顯示目前目錄的加密狀態及其包含的任何檔案。

語法

cipher [/e | /d | /c] [/s:<directory>] [/b] [/h] [pathname [...]]
cipher /k
cipher /r:<filename> [/smartcard]
cipher /u [/n]
cipher /w:<directory>
cipher /x[:efsfile] [filename]
cipher /y
cipher /adduser [/certhash:<hash> | /certfile:<filename>] [/s:directory] [/b] [/h] [pathname [...]]
cipher /removeuser /certhash:<hash> [/s:<directory>] [/b] [/h] [<pathname> [...]]
cipher /rekey [pathname [...]]

參數

參數 描述
/b 如果發生錯誤,則中止。 根據預設,即使發生錯誤,cipher 仍會繼續執行。
/c 顯示加密檔案的相關資訊。
/d 解密指定的檔案或目錄。
/e 加密指定的檔案或目錄。 會標示目錄,以便之後新增的檔案都會加密。
/h 顯示具有隱藏或系統屬性的檔案。 根據預設,不會加密或解密這些檔案。
/k 建立新的憑證和金鑰,以與加密檔案系統 (EFS) 檔案搭配使用。 如果已指定 /k 參數,則會忽略所有其他參數。
/r:<filename> [/smartcard] 產生 EFS 修復代理程式金鑰和憑證,然後將它們寫入 .pfx 檔案 (包含憑證和私密金鑰),以及 .cer 檔案 (只包含憑證)。 如果已指定 /smartcard,它會將修復金鑰和憑證寫入智慧卡,而且不會產生 .pfx 檔案。
/s:<directory> 對指定目錄中的所有子目錄執行指定的作業。
/u [/n] 尋找本機磁碟機上所有加密的檔案。 如果搭配 /n 參數使用,則不會進行任何更新。 如果沒有搭配 /n 使用,則 /u 會將使用者的檔案加密金鑰或復原代理程式的金鑰與目前的金鑰進行比較,並在發生變更時加以更新。 此參數僅適用於 /n
/w:<directory> 從整個磁碟區上可用的未使用磁碟空間中移除資料。 如果您使用 /w 參數,則會忽略所有其他參數。 指定的目錄可以位於本機磁碟區中的任何位置。 如果是掛接點或指向另一個磁碟區中的目錄,則會移除該磁碟區上的資料。
/x[:efsfile] [<FileName>] 將 EFS 憑證和金鑰備份至指定的檔名。 如果搭配 :efsfile 使用,/x 會備份用來加密檔案的使用者憑證。 否則,會備份使用者目前的 EFS 憑證和金鑰。
/y 在本機電腦上顯示您目前的 EFS 憑證縮圖。
/adduser [/certhash:<hash> /certfile:<filename>]
/rekey 更新指定的加密檔案以使用目前設定的 EFS 金鑰。
/removeuser /certhash:<hash> 從指定的檔案中移除使用者。 為 /certhash 提供的雜湊必須是要移除之憑證的 SHA1 雜湊。
/? 在命令提示字元顯示說明。

備註

  • 如果未加密父目錄,加密的檔案可能會在修改時解密。 因此,當您加密檔案時,也應該加密父目錄。

  • 系統管理員可以將 .cer 檔案的內容新增至 EFS 復原原則,以建立使用者的復原代理程式,然後匯入 .pfx 檔案以復原個別檔案。

  • 您可以使用多個目錄名稱和萬用字元。

  • 您必須在多個參數之間放置空格。

範例

若要顯示目前目錄中每個檔案和子目錄的加密狀態,請輸入:

cipher

加密的檔案和目錄會以 E 標記。未加密的檔案和目錄會以 U標記。例如,下列輸出指出目前目錄及其所有內容目前未加密:

Listing C:\Users\MainUser\Documents\
New files added to this directory will not be encrypted.
U Private
U hello.doc
U hello.txt

若要在上一個範例中使用的 Private 目錄上啟用加密,請輸入:

cipher /e private

下列輸出會顯示:

Encrypting files in C:\Users\MainUser\Documents\
Private             [OK]
1 file(s) [or directorie(s)] within 1 directorie(s) were encrypted.

cipher 命令會顯示以下輸出:

Listing C:\Users\MainUser\Documents\
New files added to this directory will not be encrypted.
E Private
U hello.doc
U hello.txt

其中 Private 目錄現已標示為加密的位置。