0

我正在尝试获取注册表项值,但我遇到了问题。

以下是我尝试执行的命令。

Get-ChildItem "HKEY_LOCAL_MACHINE\SFTWARE\Wow6432Node\Mycompany\MyProj\Model" | ForEach-Object {Get-ItemProperty $_.pspath}

但是在附加了当前工作目录的注册表项路径中,会产生如下所示的意外问题。

PS C:\Users\Administrator\Desktop\MyDoc\Core\NodeRenameMaster> Get-ChildItem "HKEY_LOCAL_MACHINE\S
FTWARE\Wow6432Node\Mycompany\MyProj\Model" | ForEach-Object {Get-ItemProperty $_.pspath}
Get-ChildItem : Cannot find path 'C:\Users\Administrator\Desktop\MyDoc\Core\NodeRenameMaster\HKEY_
LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mycompany\MyProj\Model' because it does not exist.
At line:1 char:14
+ Get-ChildItem <<<<  "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mycompany\MyProj\Model" | ForEach-Object {Get-Item
Property $_.pspath}
    + CategoryInfo          : ObjectNotFound: (C:\Users\Admini...\Model:String) [Get-ChildItem], ItemNotFound
   Exception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

为什么会发生?如何解决这个问题?

4

1 回答 1

2

路径无效,将“HKEY_LOCAL_MACHINE”替换为“HKLM:\”,将“SFTWARE”替换为“SOFTWARE”

于 2012-07-13T16:29:11.350 回答