我正在嘗試編寫一個簡單的命令來創建 .reg 檔案並導出其中的關鍵訊息,但它似乎不接受 REG EXPORT 命令,即使我以管理員身份運行它
New-Item -Path "C:\Users\operateur\Documents\Configuration.reg"
REG EXPORT "HKLM\SOFTWARE\Groupe ABC", "C:\Users\operateur\Documents\Configuration.reg"
答案1
有趣的。如果您從控制台執行命令,則會出現確認提示以覆寫現有檔案:
PS C:\...\regExport>New-Item Configuration.reg
Directory: C:\Users\keith\Sandbox\regExport
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 12/4/2020 5:26 PM 0 Configuration.reg
PS C:\...\regExport>REG EXPORT "HKLM\SOFTWARE\IrfanView", "Configuration.reg"
File Configuration.reg already exists. Overwrite (Yes/No)?
但相同的命令只是掛在 ISE 中。
你實際上是在阻止Reg Export
避免透過不必要的操作建立文件New-Item
Cmdlet,它建立一個同名的空檔。
Either eliminate the **`New-Item`** Cmdlet or use the `/y` switch with the **`Reg Export`** command.
REG EXPORT KeyName FileName [/y] [/reg:32 | /reg:64]
Keyname ROOTKEY[\SubKey] (local machine only).
ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey The full name of a registry key under the selected ROOTKEY.
FileName The name of the disk file to export.
/y Force overwriting the existing file without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64 Specifies the key should be accessed using the 64-bit registry view.