问题
I am trying to set and unset registry with values 1 and 0 respectively. I am using regedit npm package to achieve this.
Upon unset,I want this registry value to be 0. I see the function UnsetRegistryValue being called, but it doesn't set the value to 0. Please note, already registry value set to 1. I want to replace registry value
**set registry **
function setRegistryValue(){
regedit.putValue({
'HKLM\\System\\CurrentControlSet\\Control\\Session Manager\\Environment': {
'XYZ': {
value: '1',
type: 'REG_SZ'
},
'Version': { }
}
}, function(err) {app.console.log(err);});
}
**unset registry **
function UnsetRegistryValue(){
regedit.putValue({
'HKLM\\System\\CurrentControlSet\\Control\\Session Manager\\Environment': {
'XYZ': {
value: '0',
type: 'REG_SZ'
},
'Version': { }
}
}, function(err) {app.console.log(err);});
}
回答1:
Sorry, I had typo in the to set or unset or modify.You can use regedit.putValue
来源:https://stackoverflow.com/questions/56750842/setting-and-unsetting-registry-using-regedit-replace-registry-value-from-1-to-0