Script to reset COM ports
I am trying to write a script to change a HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter\ComDB REG_BINARY back to all 00 so that COM port 3 can be used as default in my virtual environment when I switch desktops. the script below is the latest one I tried but I am getting a type mismatch on line 22 and not sure how to get this to work
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
'Define byte's array
Dim bArray
strKeyPath = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter\"
'Fill array with values of the key;
'array elemnts starts from 0 an up,
'so I need to change bArray(2) element's value
objReg.GetBinaryValue HKEY_LOCAL_MACHINE, strKeyPath, "ComDB", bArray
'Changing value
bArray = 00
'Write infromation back
objReg.SetBinaryValue HKEY_LOCAL_MACHINE, strKeyPath, "ComDB", bArray
Set objReg = Nothing
Answers (1)
If I am understanding this correctly, in your script you have set "type" is bArray. I do not think this is a registry type. You should use REG_BINARY for ComDB I believe but registry can be deep and daunting.
Have you tried a kscript? I REALLY like using this for registry stuff. I do a check and change values using this all the time with confidence. Lots of actions to use: