尝试使用 PowerShell 2.0 将 regfile 复制到另一个文件夹

Trying to copy regfile with PowerShell 2.0 to another folder

我正在尝试使用 PowerShell 2.0 将 HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INIHKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI regfile 导出到另一个驱动器。

我已阅读 this Whosebug post 但我只收到带有该代码的错误消息。这可能是因为我使用的是 v2.0。我不能使用更高版本。

有没有人知道为什么它不起作用或者如何使用 PowerShell v2.0 将它们复制到另一个驱动器?

代码

reg copy HKCU\Software\ODBC\ODBC.INI H:\temp /s /f

错误

reg.exe : ERROR: Invalid key name.
At line:1 char:4
+ reg <<<<  copy HKCU\Software\ODBC\ODBC.INI H:\temp /s /f
    + CategoryInfo          : NotSpecified: (ERROR: Invalid key name.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Type "REG COPY /?" for usage.

reg copy is for copying data from one registry key to another registry key, not for exporting registry keys to a file. That's what reg export 用于.

reg export HKCU\Software\ODBC\ODBC.INI H:\temp\odbc_ini.reg /y

reg.exe为外部命令,与PowerShell版本无关