/build/static/layout/Breadcrumb_cap_w.png

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


0 Comments   [ + ] Show comments

Answers (1)

Posted by: Michelle.ashby 3 years ago
Purple Belt
0

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:
cUD9By9AAAAAElFTkSuQmCCwH83K90RcZ9OwAAAABJRU5ErkJggg==

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ