操作注册表,dir 后面的路径是由变量拼接的字符串,报错
$net_key="xxx-xxx-xx"
$key_path_str="HKLM:\SYSTEM\CurrentControlSet\Control\Network\ -recurse -include `""+$net_key+"`""
dir $key_path_str的时候报错,
得到的字符串为:HKLM:\SYSTEM\CurrentControlSet\Control\Network\ -recurse -include "{AA7735AF-FB9F-483D-8F89-A0DEC99ECAD3}"
错误信息为:把HKLM:自动替换成了'HKEY_LOCAL_MACHINE
dir : Cannot find path 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\ -recurse -include "{AA7735AF-FB9F-483D-8F89-A0DEC99ECAD3}"' because it does not exist
请问怎么解决