Set-ItemProperty sets Registry Value as String on some systems instead of DWord, why?

陌路散爱 提交于 2019-11-30 17:17:38

I don't have an answer to why it happens but to avoid such instances, be explicit. Use the Type (dynamic) Parameter and specify a RegistryValueKind value (you can also use it with New-ItemProperty) :

Set-ItemProperty -Path HKCR:\Software\MyCompany -Name Level -Value 5 -Type DWord

Try this.

[Microsoft.Win32.Registry]::SetValue("HKEY_CLASSES_ROOT\Software\MyCompany","Level",5,[Microsoft.Win32.RegistryValueKind]::DWord)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!