仅修改/删除部分注册表值 [英] Modifying/removing only part of a registry value

查看:153
本文介绍了仅修改/删除部分注册表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定是否可以这样做

i'm not sure if this can be done

我必须检查两个不同的注册表项。 

i have to check on two different registry keys. 

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet \Control\NetworkProvider \HwOrder

HKEY_LOCAL_MACHINE \SYSTEM\CurrentControlSet \Control\NetworkProvider \Order

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\HwOrder
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order

根据计算机的不同,每个键中有4-6个值由逗号分隔, 。我需要能够检查键并删除其中一个值及其逗号,同时在每个键上保留其他值。 

depending on the computer, in each of the keys there are between 4-6 values seperated by a comma,  . i need to be able to check the keys and remove one of those values, and its comma, while leaveing the other values alone, on each of the keys. 

如果所有值是相同的,这很容易,但在查询密钥后不确定,在重写/修改值时使其排除该值。  

if all the values were the same this would be easy, but not sure after the key is queryed, to make it exclude that value, when re-writing/modifying the values.  

其中一个键有  DPNP,LanmanWorkstation,webclient, SCP

one of the keys would have something like DPNP,LanmanWorkstation,webclient,SCP

SCP是我要删除的值,而剩下的则是。  ;

SCP is the value i want to remove, while leaving the rest. 

我似乎无法单独留下其他价值 

i can't seem to get it to leave the other values alone  

谢谢.. 

thanks.. 

推荐答案

您可以使用Get-ItemProperty和Set-ItemProperty来获取和设置注册表值

You can use Get-ItemProperty and Set-ItemProperty to get and set registry values

您可以使用-split运算符将值拆分为多个对象,然后可以使用诸如where-object之类的东西进行过滤,然后使用-join运算符将它们放回到单个字符串中逗号分隔。

You can use the -split operator to split your value into multiple objects that you can then filter using something like where-object and then use the -join operator to put them back into a single string that is comma separated.


这篇关于仅修改/删除部分注册表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆