为什么powershell会抛出路径不存在错误?

问题描述 投票:0回答:1

为什么在尝试从我使用的docs创建或修改注册表项时,powershell 会抛出错误

Set-ItemProperty -Path "HKLM:\Software\ContosoCompany" -Name "NoOfEmployees" -Value 823

我得到的错误

Set-ItemProperty : Cannot find path 'HKLM:\Software\ContosoCompany' because it does not exist.
At line:1 char:1
+ Set-ItemProperty -Path "HKLM:\Software\ContosoCompany" -Name "NoOfEmp ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HKLM:\Software\ContosoCompany:String) [Set-ItemProperty], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetItemPropertyCommand

我以管理员身份运行 powershell,我尝试修改现有密钥并尝试创建新密钥,但我仍然收到此错误

powershell registry
1个回答
1
投票

HKLM 是“驱动器”的名称。先搬过去

Set-Location HKLM:

Set-ItemProperty -Path "HKLM:\Software\ContosoCompany" -Name "NoOfEmployees" -Value 823
© www.soinside.com 2019 - 2024. All rights reserved.