我正在尝试编写一个简单的命令来创建一个 .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.